-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat: initial implementation of microprofile-openapi-3 #483
base: main
Are you sure you want to change the base?
Conversation
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
...com/github/victools/jsonschema/module/microprofile/openapi3/integration-test-result-Foo.json
Outdated
Show resolved
Hide resolved
e59cec4
to
ced7387
Compare
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
.../com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java
Outdated
Show resolved
Hide resolved
ced7387
to
7db5831
Compare
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
...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
Outdated
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
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ New issue: Complex Method
overrideInstanceAttributes has a cyclomatic complexity of 11, threshold = 9
…d Schema.True should be taken into account
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
...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
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); | ||
} |
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.
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.
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.
By removing this bloc and keep MicroProfileOpenApi3AnyOfResolver
my test on Foo.class
is failing.
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.03 (9.69 -> 9.72)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.03 (9.69 -> 9.72)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.03 (9.69 -> 9.72)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.03 (9.69 -> 9.72)
- Declining Code Health: 1 findings(s) 🚩
e604d73
to
674d3ff
Compare
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
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.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.04 (9.69 -> 9.73)
- Declining Code Health: 1 findings(s) 🚩
No description provided.