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

Add x-nullable (OAS2) support #889

Merged
merged 2 commits into from
Aug 25, 2018
Merged

Add x-nullable (OAS2) support #889

merged 2 commits into from
Aug 25, 2018

Conversation

wing328
Copy link
Member

@wing328 wing328 commented Aug 23, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.3.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

A follow up PR to #873

@jmini
Copy link
Member

jmini commented Aug 24, 2018

The x-nullable can be added to parameter?

What will be the result of (OAS3 example) a parameter and a Schema not telling the same:

      parameters:
        - name: petId
          in: path
          description: ID of pet that needs to be updated
          required: true
          x-nullable: false
          schema:
            type: integer
            format: int64
            nullable: true

Is this consistently treated?

@wing328
Copy link
Member Author

wing328 commented Aug 24, 2018

Very good question. OAS3 shouldn't use/need x-nullable as the schema supports nullable already.

@wing328 wing328 merged commit 50c6ac3 into master Aug 25, 2018
@wing328 wing328 deleted the nullable_extension branch August 25, 2018 10:31
@jmini
Copy link
Member

jmini commented Aug 29, 2018

The potential conflict between x-nullable and nullable in OAS3 needs to be solved (see previous discussion). Maybe the solution is to log a warning or a validation issue when there are conflicts.

x-nullable for OAS2 requires a Swagger-Parser update which is planned for 3.3.0.

My take is that with 3.2.3 the feature will be useless.

@jmini
Copy link
Member

jmini commented Aug 29, 2018

While I was investing, I have seen, the the conversion

  • from OAS2 x-nullable on a paramter
  • to OAS3 nullable in the schema of the parameter

is already correctly implemented by Swagger-Parser.

This means the code proposed by #873 will already work with OAS2 and that this PR introduces unnecessary code that can be reverted.

@jmini
Copy link
Member

jmini commented Aug 30, 2018

See follow up PR: #930

cognifloyd added a commit to cognifloyd/swagger-codegen that referenced this pull request Oct 13, 2018
When I wrote this, I missed the changes on CodegenParameter and I had
some unnecessary changes on CodegenModel. I realized my mistake when I
went to add a similar change to openapi-generator and saw it was already
there, and they knew more about what to do than I did.

So, this is based in part on work by @wing328 and @jmini
- OpenAPITools/openapi-generator#873
- OpenAPITools/openapi-generator#889
- OpenAPITools/openapi-generator#930
cognifloyd added a commit to cognifloyd/swagger-codegen-generators that referenced this pull request Oct 13, 2018
Requires: swagger-api/swagger-codegen#8809

When I wrote this, I missed the changes on CodegenParameter and I had
some unnecessary changes on CodegenModel. I realized my mistake when I
went to add a similar change to openapi-generator and saw it was already
there, and they knew more about what to do than I did.

So, this is based in part on work by @wing328 and @jmini
- OpenAPITools/openapi-generator#873
- OpenAPITools/openapi-generator#889
- OpenAPITools/openapi-generator#930
cognifloyd added a commit to cognifloyd/swagger-codegen that referenced this pull request Oct 13, 2018
When I wrote this, I missed the changes on CodegenParameter and I had
some unnecessary changes on CodegenModel. I realized my mistake when I
went to add a similar change to openapi-generator and saw it was already
there, and they knew more about what to do than I did.

So, this is based in part on work by @wing328 and @jmini
- OpenAPITools/openapi-generator#873
- OpenAPITools/openapi-generator#889
- OpenAPITools/openapi-generator#930
cognifloyd added a commit to cognifloyd/swagger-codegen-generators that referenced this pull request Dec 19, 2018
Requires: swagger-api/swagger-codegen#8809

When I wrote this, I missed the changes on CodegenParameter and I had
some unnecessary changes on CodegenModel. I realized my mistake when I
went to add a similar change to openapi-generator and saw it was already
there, and they knew more about what to do than I did.

So, this is based in part on work by @wing328 and @jmini
- OpenAPITools/openapi-generator#873
- OpenAPITools/openapi-generator#889
- OpenAPITools/openapi-generator#930
cognifloyd added a commit to cognifloyd/swagger-codegen-generators that referenced this pull request Dec 19, 2018
Requires: swagger-api/swagger-codegen#8809

When I wrote this, I missed the changes on CodegenParameter and I had
some unnecessary changes on CodegenModel. I realized my mistake when I
went to add a similar change to openapi-generator and saw it was already
there, and they knew more about what to do than I did.

So, this is based in part on work by wing328 and jmini
- OpenAPITools/openapi-generator#873
- OpenAPITools/openapi-generator#889
- OpenAPITools/openapi-generator#930
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* add x-nullable oas2 support

* add test spec for testing x-nullable
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.

2 participants