openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

field required (type=value_error.missing)

Open cristiang777 opened this issue 2 years ago • 5 comments

Hi, I'm sure this is related to my project, not to the openapi-python-client, but needed some help. When running the app, I get the following errors:

Error(s) encountered while generating, client was not created

Failed to parse OpenAPI document

50 validation errors for OpenAPI
paths -> /auth/login -> post -> requestBody -> content -> application/x-www-form-urlencoded -> schema -> $ref
  field required (type=value_error.missing)
paths -> /auth/login -> post -> requestBody -> content -> application/x-www-form-urlencoded -> schema -> properties -> user -> $ref
  field required (type=value_error.missing)
paths -> /auth/login -> post -> requestBody -> content -> application/x-www-form-urlencoded -> schema -> properties -> user -> required
  value is not a valid list (type=type_error.list)
paths -> /auth/login -> post -> requestBody -> content -> application/x-www-form-urlencoded -> schema -> properties -> password -> $ref
  field required (type=value_error.missing)
paths -> /auth/login -> post -> requestBody -> content -> application/x-www-form-urlencoded -> schema -> properties -> password -> required
....

And here's some of api.yaml file that I'm using:

paths:
  /auth/login:
    post:
      tags:
      - Auth
      summary: Authenticate with API
      description: Authenticate with API getting bearer token
      requestBody:
        description: Request values
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                user:
                  description: API user name
                  type: string
                  required: true
                password:
                  description: API password
                  type: string
                  required: true
            required:
              - user
              - password

Any thoughts on what's wrong?

cristiang777 avatar Oct 04 '22 22:10 cristiang777

bump, encountering the same issue.

kraktus avatar Apr 13 '23 21:04 kraktus

Did you ever find a fix?

harrystuart avatar Aug 03 '23 04:08 harrystuart

Unfortunately not

kraktus avatar Aug 03 '23 06:08 kraktus

This just happened to me with the sentry openapi schema, which is openapi version v3.0.3. I tried to load the schema directly with openapi-pydantic (see here) which worked fine. It seems like openapi-python-client bundles its own version of openapi-pydantic which does not work with v3.0.3. I did a quick and dirty try to replace the included version (in openapi_python_client/schema/) with the latest upstream openapi-pydantic which needed some little adjustments but worked fine overall. @dbanty are there any special reasons for the vendored version?

benedikt-bartscher avatar Dec 18 '23 13:12 benedikt-bartscher

It needed a bunch of customizations to work the way I needed. It could be that the latest version works much better, but it'd take a lot of validation to be sure

dbanty avatar Dec 18 '23 16:12 dbanty