Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Null type #16

Closed
wants to merge 27 commits into from
Closed

Support Null type #16

wants to merge 27 commits into from

Conversation

sebastien-rosset
Copy link

@sebastien-rosset sebastien-rosset commented Feb 1, 2020

Not ready to submit as PR to upstream.

In OAS 3.1, the 'null' type is supported. This PR adds support for the 'null' type and partially provides a fix for OpenAPITools#5180. As an example, a schema may be defined as:

type: 'null'

This is useful in the following scenario when a property may be null or some referenced complex type:

Order:
  type: object
  properties:
    billTo:
      oneOf:
      - type: 'null'
      - $ref: "#/definitions/Address"

The python-experimental module performs a strict validation of the server response. If the response is null but the OAS schema does not allow null values, the client raises an exception such as the one below:

Exception when calling API: Invalid type for variable 'parent'.
Required value type is MoOptionalBaseMo and passed type was NoneType at
['received_data']['results'][0]['parent']

TODO:

  1. Fail validation if openapi version is 3.0, AND one of the type is 'null' or one of the type is an array.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant