-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[Java][Jersey2] Add JsonTypeName annotation #6551
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
Merged
wing328
merged 63 commits into
OpenAPITools:master
from
CiscoM31:jersey2-subtype-annotation
Jul 18, 2020
Merged
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
41e97e6
Mustache template should use invokerPackage tag to generate import
sebastien-rosset 1760f6a
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 3ae466e
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset b628667
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 4dc915c
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 7a207f6
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 776fba6
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 3fac434
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset a96c46b
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 1351fd0
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset ba65735
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 9a0b89e
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 4c84190
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 94ae683
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset aac9f5a
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 93baa3d
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 5c313b4
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset cda8898
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 1f7e5c1
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset bef435e
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset a9cad38
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 877ecfe
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 8c055f5
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset d64f421
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 4d0edfe
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 476eb01
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 8ff6088
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset ac1a061
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 8579966
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 7c45925
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 7f52a53
Merge remote-tracking branch 'upstream/master'
vvb 76d3348
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 797e779
Merge branch 'master' of github.com:CiscoM31/openapi-generator
sebastien-rosset 700e0f9
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset cf45a86
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset ad3fa7e
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 12ecf34
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 6321dfc
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset c05b82e
add JsonSubTypes annotation to handle scenario when OAS name has spec…
sebastien-rosset 92eadd7
add JsonSubTypes annotation to handle scenario when OAS name has spec…
sebastien-rosset ae8e870
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset a8d8b96
Merge branch 'master' of github.com:CiscoM31/openapi-generator into j…
sebastien-rosset 97e490e
run sample scripts
sebastien-rosset 3237fc6
fix unit test
sebastien-rosset d1f351b
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 5e2f013
run sample scripts
sebastien-rosset 5d7aa84
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset 76996aa
Merge branch 'master' of https://github.com/OpenAPITools/openapi-gene…
sebastien-rosset a873091
resolve merge conflicts
sebastien-rosset 6ff9965
resolve merge conflicts. sync from master
sebastien-rosset ed663e0
add minimal openapi document to show issue with special characters an…
sebastien-rosset db62818
Add 'isClassnameSanitized' tag
sebastien-rosset b312cee
Add 'isClassnameSanitized' tag
sebastien-rosset 12bfcd4
Add 'isClassnameSanitized' tag
sebastien-rosset c4a42a3
Add 'isClassnameSanitized' tag
sebastien-rosset e701504
Add 'isClassnameSanitized' tag
sebastien-rosset 72f6a30
Add 'isClassnameSanitized' tag
sebastien-rosset 9636649
Merge branch 'master' of github.com:CiscoM31/openapi-generator into j…
sebastien-rosset 27a0c6c
Add unit tests for unmarshaling of discriminators with special charac…
sebastien-rosset 05b168f
Merge branch 'master' of github.com:CiscoM31/openapi-generator into j…
sebastien-rosset da0dcc1
Add unit tests for unmarshaling of discriminators with special charac…
sebastien-rosset 2a4c15a
Merge branch 'master' of github.com:CiscoM31/openapi-generator into j…
sebastien-rosset 1f5fc0c
use JsonTypeName
wing328 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
generatorName: java | ||
outputDir: samples/openapi3/client/petstore/java/jersey2-java8-special-characters | ||
library: jersey2 | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/schema-with-special-characters.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/Java | ||
additionalProperties: | ||
artifactId: petstore-openapi3-jersey2-java8-special-characters | ||
hideGenerationTimestamp: true | ||
serverPort: "8082" | ||
dateLibrary: java8 | ||
useOneOfDiscriminatorLookup: true | ||
disallowAdditionalPropertiesIfNotPresent: false | ||
systemProperties: | ||
skipValidateSpec: "false" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
modules/openapi-generator/src/main/resources/Java/typeInfoAnnotation.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
{{#jackson}} | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true) | ||
{{#discriminator.mappedModels}} | ||
{{#-first}} | ||
@JsonSubTypes({ | ||
{{#discriminator.mappedModels}} | ||
{{/-first}} | ||
@JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), | ||
{{/discriminator.mappedModels}} | ||
}){{/jackson}} | ||
{{#-last}} | ||
}) | ||
{{/-last}} | ||
{{/discriminator.mappedModels}} | ||
{{#isClassnameSanitized}} | ||
@JsonTypeName("{{name}}") | ||
{{/isClassnameSanitized}} | ||
{{/jackson}} |
71 changes: 71 additions & 0 deletions
71
modules/openapi-generator/src/test/resources/3_0/schema-with-special-characters.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
openapi: 3.0.3 | ||
info: | ||
description: test | ||
version: 1.0.0 | ||
title: test | ||
paths: | ||
/test: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/MySchemaName._-Characters' | ||
responses: | ||
'200': | ||
description: the response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/MySchemaName._-Characters' | ||
components: | ||
schemas: | ||
Parent: | ||
properties: | ||
objectType: | ||
type: string | ||
discriminator: | ||
propertyName: objectType | ||
ChildSchema: | ||
description: A schema that does not have any special character. | ||
allOf: | ||
- $ref: '#/components/schemas/Parent' | ||
- type: object | ||
properties: | ||
prop1: | ||
type: string | ||
# Note: the name below with non-ASCII characters is a valid JSON schema name, | ||
# however currently OpenAPI generator does not allow special characters beyond [.-_] | ||
# | ||
# The set of allowed characters for OpenAPI schema names is specified in RFC 8259 | ||
# at https://tools.ietf.org/html/rfc8259. | ||
# The OpenAPI schema uses the JSON schema specification, which references RFC 8259. | ||
# A string is a sequence of zero or more Unicode characters [UNICODE]. | ||
# Note that this citation references the latest version of Unicode | ||
# rather than a specific release. Any character may be escaped. | ||
# MySchemaNameWithUnusual#$12.3!@#%🍇🍅😀🏄🏾♂️Characters: | ||
MySchemaName._-Characters: | ||
description: | ||
A schema name that has letters, numbers, punctuation and non-ASCII characters. | ||
The sanitization rules should make it possible to generate a language-specific | ||
classname with allowed characters in that programming language. | ||
allOf: | ||
- $ref: '#/components/schemas/Parent' | ||
- type: object | ||
properties: | ||
prop2: | ||
type: string | ||
# Below is a schema with the same name, except special characters have been removed. | ||
# This causes a codegen issue because the generated code will have exactly the same class name | ||
# as the above 'MySchemaName._-Characters'. | ||
# Hence the schema is commented out for now. | ||
# | ||
#MySchemaNameCharacters: | ||
# description: | ||
# A schema with same name as above, without the special characters. | ||
# allOf: | ||
# - $ref: '#/components/schemas/Parent' | ||
# - type: object | ||
# properties: | ||
# prop2: | ||
# type: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 , fyi
MySchemaNameWithUnusual#$12.3!@#%🍇🍅😀🏄🏾♂️Characters
is a valid JSON schema name, but OpenAPI generator does not allow this.