Skip to content

Conversation

@bflaton
Copy link
Contributor

@bflaton bflaton commented Sep 7, 2021

Update of PR 10331 which was reverted because some tests were failing. This PR also includes fixes for those tests.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

…nction parameters nicely in IDE.

Endpoints are still accessible in generated code, mainly to satisfy some test cases.
@bflaton
Copy link
Contributor Author

bflaton commented Sep 7, 2021

As indicated by the PR checklist, mentioning the technical committee.. sorry if i misunderstood and now spam you all ;-)

@taxpon @frol @mbohlool @cbornet @kenjones-cisco @tomplus @Jyhess @arun-nalla @spacether

@spacether
Copy link
Contributor

@bflaton can you rebase this on master?
#10354
just landed which turns python testing back on in circleci.

@spacether
Copy link
Contributor

spacether commented Sep 9, 2021

re-triggering circleci because it hit a concurrency limit :(
Thank you for merging master in

@bflaton
Copy link
Contributor Author

bflaton commented Sep 9, 2021

sorry spacether, didn't see your comment, but branch was one commit behind again, so performed another merge to trigger build as well

@bflaton
Copy link
Contributor Author

bflaton commented Sep 14, 2021

@spacether do you still want me to make some changes? Or would you care to try another merge ;-) No conflicts with master right now, but if you want i can always eagerly merge master.

@spacether spacether added this to the 5.3.0 milestone Sep 14, 2021
Copy link
Contributor

@spacether spacether left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for your PR!

@spacether spacether merged commit 9479d35 into OpenAPITools:master Sep 14, 2021
@bflaton bflaton deleted the python-client-docstring branch October 6, 2021 09:05
@mheguy
Copy link
Contributor

mheguy commented Mar 18, 2022

Heya,
How many times have you guys heard this before... "This change broke my weird workflow".
Well today that weird workflow is mine.
I updated openapi-generator and things started breaking.

I use an oauth2 with pkce authentication flow for my tools, and sometimes the authentication token expires before the tool has finished running. So, I put a refresh attempt into a function that handles errors in my API calls. The problem I have is that I would put the token into api.endpoint.api_client.configuration.access_token which no longer exists because api.endpoint is actually a method.

I was wondering if anybody has a suggestion on how I might easily reach the api_client from the method that is being passed.

def try_cs_call(
    endpoint: Any,
    *args: Any,
    _raise_exception: bool = True,
    _retries: int = 2,
    **kwargs: Any,
) -> Any:
    """Safely call an API endpoint.

    Args:
        endpoint (Any): endpoint to call
        _raise_exception (bool): Whether to raise an exception on fail or not. Defaults to True.

    Returns:
        Any: returns any type of response model
    """
    response = None
    for _ in range(_retries):
        try:
            response = endpoint(*args, **kwargs)
            cs_response_check(response, _raise_exception)
            break
        except UnauthorizedException:
            logger.debug("Access token expired, attempting refresh..")
            config = endpoint.api_client.configuration
            config.access_token = config.keycloak_client.get_oauth_token()
        except sbcs.ApiException as exc:
            endpoint_name = endpoint.settings["operation_id"]
            print(f"Exception when calling {endpoint_name}: {exc}\n")
            sys.exit()
    else:
        raise UnauthorizedException("CS refused authorization")
    return response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants