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

feat: initial implementation of microprofile-openapi-3 #483

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dcdh
Copy link

@dcdh dcdh commented Oct 12, 2024

No description provided.

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

@dcdh dcdh changed the title microprofile-openapi-3 initial implementation feat: initial implementation of microprofile-openapi-3 Oct 12, 2024
Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

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);
}
}

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

Suppress

…d Schema.True should be taken into account
Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

jsonschema-module-microprofile-openapi-3/README.md 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);
}
Copy link
Member

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.

Copy link
Author

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.

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) 🚩

View detailed results in CodeScene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants