0

I would like to use https://github.com/OpenAPITools/openapi-generator to generate a python sdk from the yaml behind https://api-docs.firefly-iii.org/

Currently, the YAML contains this securityScheme:

securitySchemes:
    firefly_iii_auth:
      type: oauth2
      description: Default OAuth2 flow
      flows:
        authorizationCode:
          authorizationUrl: https://demo.firefly-iii.org/oauth/authorize
          tokenUrl: https://demo.firefly-iii.org/oauth/token
          refreshUrl: https://demo.firefly-iii.org/oauth/token
          scopes: {}
    local_bearer_auth:
      description: Optional Bearer token flow
      type: http
      scheme: bearer

The above schema is translated by openapi-generator to the following snippet in configuration.py:

class Configuration(object):
    _default = None

    def __init__(
        self,
        host=None,
        discard_unknown_keys=False,
        disabled_client_side_validations="",
        server_index=None,
        server_variables=None,
        server_operation_index=None,
        server_operation_variables=None,
        access_token=None,
    ):
        ...
        self.access_token = None

I'm start an openapi client with

configuration = openapi_client.Configuration(
  host = os.environ["FIREFLY_III_API_URL"],
  access_token = os.environ["FIREFLY_III_TOKEN"]
)
client = openapi_client.ApiClient(configuration)

Changing self.access_token = access_token makes authentication to work. Without it, the server returns an Unauthenticated error.

How could I extend the YAML schema to get the right generated code?

1 Answer 1

0

You can use setter to set access_token something as below: configuration.access_token = 'AccessToken' instead of the constructor:

object.Configuration(
    host = "HostURL",
    access_token = 'AccessToken')

I think due to a bug 'Access_token' in constructor is set to none, but using setter its working.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.