feat: initial implementation of microprofile-openapi-3#483
Open
dcdh wants to merge 10 commits intovictools:mainfrom
Open
feat: initial implementation of microprofile-openapi-3#483dcdh wants to merge 10 commits intovictools:mainfrom
dcdh wants to merge 10 commits intovictools:mainfrom
Conversation
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Show resolved
Hide resolved
dcdh
commented
Oct 12, 2024
...com/github/victools/jsonschema/module/microprofile/openapi3/integration-test-result-Foo.json
Outdated
Show resolved
Hide resolved
e59cec4 to
ced7387
Compare
dcdh
commented
Oct 12, 2024
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Show resolved
Hide resolved
ced7387 to
7db5831
Compare
...en-plugin/src/main/java/com/github/victools/jsonschema/plugin/maven/SchemaGeneratorMojo.java
Outdated
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Show resolved
Hide resolved
...com/github/victools/jsonschema/module/microprofile/openapi3/integration-test-result-Foo.json
Outdated
Show resolved
Hide resolved
...com/github/victools/jsonschema/module/microprofile/openapi3/integration-test-result-Foo.json
Show resolved
Hide resolved
Comment on lines
+459
to
+508
| protected void overrideInstanceAttributes(ObjectNode memberAttributes, MemberScope<?, ?> member, SchemaGenerationContext context) { | ||
| Schema annotation = this.getSchemaAnnotationValue(member, Function.identity(), x -> true) | ||
| .orElse(null); | ||
| if (annotation == null) { | ||
| return; | ||
| } | ||
| if (annotation.not() != Void.class) { | ||
| memberAttributes.set(context.getKeyword(SchemaKeyword.TAG_NOT), | ||
| context.createDefinitionReference(context.getTypeContext().resolve(annotation.not()))); | ||
| } | ||
| if (annotation.allOf().length > 0) { | ||
| ArrayNode allOfArray = memberAttributes.withArray(context.getKeyword(SchemaKeyword.TAG_ALLOF)); | ||
| Stream.of(annotation.allOf()) | ||
| .map(context.getTypeContext()::resolve) | ||
| .map(context::createDefinitionReference) | ||
| .forEach(allOfArray::add); | ||
| } | ||
| if (annotation.anyOf().length > 0) { | ||
| ArrayNode allOfArray = memberAttributes.withArray(context.getKeyword(SchemaKeyword.TAG_ALLOF)); | ||
| ArrayNode anyOfArray = allOfArray.addObject().withArray(context.getKeyword(SchemaKeyword.TAG_ANYOF)); | ||
| Stream.of(annotation.anyOf()) | ||
| .map(context.getTypeContext()::resolve) | ||
| .map(context::createDefinitionReference) | ||
| .forEach(anyOfArray::add); | ||
| } | ||
| if (annotation.oneOf().length > 0) { | ||
| ArrayNode allOfArray = memberAttributes.withArray(context.getKeyword(SchemaKeyword.TAG_ALLOF)); | ||
| ArrayNode oneOfArray = allOfArray.addObject().withArray(context.getKeyword(SchemaKeyword.TAG_ONEOF)); | ||
| Stream.of(annotation.oneOf()) | ||
| .map(context.getTypeContext()::resolve) | ||
| .map(context::createDefinitionReference) | ||
| .forEach(oneOfArray::add); | ||
| } | ||
| if (annotation.minProperties() > 0) { | ||
| memberAttributes.put(context.getKeyword(SchemaKeyword.TAG_PROPERTIES_MIN), annotation.minProperties()); | ||
| } | ||
| if (annotation.maxProperties() > 0) { | ||
| memberAttributes.put(context.getKeyword(SchemaKeyword.TAG_PROPERTIES_MAX), annotation.maxProperties()); | ||
| } | ||
| if (annotation.requiredProperties().length > 0) { | ||
| Set<String> alreadyMentionedRequiredFields = new HashSet<>(); | ||
| ArrayNode requiredFieldNames = memberAttributes | ||
| .withArray(context.getKeyword(SchemaKeyword.TAG_REQUIRED)); | ||
| requiredFieldNames | ||
| .forEach(arrayItem -> alreadyMentionedRequiredFields.add(arrayItem.asText())); | ||
| Stream.of(annotation.requiredProperties()) | ||
| .filter(field -> !alreadyMentionedRequiredFields.contains(field)) | ||
| .forEach(requiredFieldNames::add); | ||
| } | ||
| } |
There was a problem hiding this comment.
❌ New issue: Complex Method
overrideInstanceAttributes has a cyclomatic complexity of 11, threshold = 9
…d Schema.True should be taken into account
dcdh
commented
Oct 12, 2024
...thub/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3AnyOfResolver.java
Show resolved
Hide resolved
...thub/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3AnyOfResolver.java
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
Comment on lines
+477
to
+484
| if (annotation.anyOf().length > 0) { | ||
| ArrayNode allOfArray = memberAttributes.withArray(context.getKeyword(SchemaKeyword.TAG_ALLOF)); | ||
| ArrayNode anyOfArray = allOfArray.addObject().withArray(context.getKeyword(SchemaKeyword.TAG_ANYOF)); | ||
| Stream.of(annotation.anyOf()) | ||
| .map(context.getTypeContext()::resolve) | ||
| .map(context::createDefinitionReference) | ||
| .forEach(anyOfArray::add); | ||
| } |
Member
There was a problem hiding this comment.
suggestion: As per my other comment, I suggest letting the anyOf options be handled as subtypes. This may resolut in a cleaner schema being generated.
Author
There was a problem hiding this comment.
By removing this bloc and keep MicroProfileOpenApi3AnyOfResolver my test on Foo.class is failing.
e604d73 to
674d3ff
Compare
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


No description provided.