Skip to content

Handle discriminator mapping non-ref name#3247

Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom
kevinoid:discriminator-mapping-to-name
Jul 4, 2019
Merged

Handle discriminator mapping non-ref name#3247
wing328 merged 1 commit intoOpenAPITools:masterfrom
kevinoid:discriminator-mapping-to-name

Conversation

@kevinoid
Copy link
Copy Markdown
Contributor

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, ./bin/openapi3/{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\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.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

The mapping property of the Discriminator Object is "An object to hold mappings between payload values and schema names or references." The subsequent examples in the spec have mappings of both types. The mapping support introduced in #536 only supports references.

This pull request updates the code to support names which are not references (identified by lack of /) in addition to references and changes a test mapping to cover this case.

Thanks for considering,
Kevin

CC: @0v1se, @jmini (from #536)
CC technical committee: @bbdouglas, @sreeshas, @jfiala, @lukoyanov, @cbornet, @jeff9finger, @karismann, @Zomzog

The `mapping` property of the [Discriminator Object] is "An object to
hold mappings between payload values and schema names or references."
The subsequent examples in the spec have `mapping`s of both types.
The `mapping` support introduced in OpenAPITools#536 only supports references.

Update the code to support names (identified by lack of `/`) or
references and change a test mapping to cover this case.

[Discriminator Object]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#discriminatorObject

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Copy link
Copy Markdown
Member

@wing328 wing328 left a comment

Choose a reason for hiding this comment

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

LGTM. Tested locally and the result is good.

@wing328 wing328 merged commit 2c342cc into OpenAPITools:master Jul 4, 2019
@wing328 wing328 added this to the 4.0.3 milestone Jul 4, 2019
@wing328 wing328 changed the title [Java] Handle discriminator mapping non-ref name Handle discriminator mapping non-ref name Jul 4, 2019
@kevinoid
Copy link
Copy Markdown
Contributor Author

kevinoid commented Jul 4, 2019

Great. Thanks @wing328!

kevinoid added a commit to kevinoid/appveyor-swagger that referenced this pull request Nov 17, 2022
openapi-generator currently does not generate valid Java code for
discriminator mappings with names (instead of references).  So use
references instead.

See OpenAPITools/openapi-generator#3247

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/appveyor-swagger that referenced this pull request Nov 17, 2022
openapi-generator currently does not generate valid Java code for
discriminator mappings with names (instead of references).  So use
references instead.

See OpenAPITools/openapi-generator#3247

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/appveyor-swagger that referenced this pull request Nov 17, 2022
openapi-generator currently does not generate valid Java code for
discriminator mappings with names (instead of references).  So use
references instead.

See OpenAPITools/openapi-generator#3247

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/appveyor-swagger that referenced this pull request Nov 18, 2022
openapi-generator currently does not generate valid Java code for
discriminator mappings with names (instead of references).  So use
references instead.

See OpenAPITools/openapi-generator#3247

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
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