-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[JAVA] new Feature interface: Documentation Provider and Annotation Library #11258
[JAVA] new Feature interface: Documentation Provider and Annotation Library #11258
Conversation
@wing328 @welshm |
Docs and samples not updated yet - I'll wait for potential feedback and feasibility check. |
I'll try to take a look at this later today (EST) |
DocumentationProvider
AnnotationLibrary
|
Output of
|
0320e69
to
4aaec1d
Compare
.../openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
Outdated
Show resolved
Hide resolved
@@ -63,13 +63,13 @@ public class OpenAPI2SpringBoot implements CommandLineRunner { | |||
.allowedMethods("*") | |||
.allowedHeaders("Content-Type"); | |||
}*/ | |||
{{^useSpringfox}} | |||
{{^springFoxDocumentationProvider}} |
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.
Is this the right check? Or is the resource handler needed for specific non-Springfox providers?
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.
I just replaced the template variable name - not the logic
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.
Hmmm... I suspect this will cause issues with some configurations but we can find out later
NONE("withoutDocumentationProvider", "Do not publish an OpenAPI specification.", | ||
AnnotationLibrary.NONE, AnnotationLibrary.values()), | ||
|
||
SOURCE("sourceDocumentationProvider", "Publish the original input OpenAPI specification.", | ||
AnnotationLibrary.NONE, AnnotationLibrary.values()), | ||
|
||
SWAGGER1("swagger1DocumentationProvider", "Generate a Swagger 2 specification using Swagger-Core 1.x.", | ||
AnnotationLibrary.SWAGGER1, AnnotationLibrary.SWAGGER1), | ||
|
||
SWAGGER2("swagger2DocumentationProvider", "Generate an OpenAPI 3 specification using Swagger-Core 2.x.", | ||
AnnotationLibrary.SWAGGER2, AnnotationLibrary.SWAGGER2), | ||
|
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.
Is the plan to add support for these providers before submitting this PR?
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.
No - at least not in the spring generator. General Idea ist that other generators should use the same cli options and template variables to make the project easier to maintain in the long run.
If it is decided to make it spring generator only, I would probably remove those Enum values.
...src/main/java/org/openapitools/codegen/languages/features/DocumentationProviderFeatures.java
Outdated
Show resolved
Hide resolved
# Conflicts: # modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java # modules/openapi-generator/src/main/resources/JavaSpring/api.mustache # modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache # modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache
I merged in master and resolved conflicts after #11229. This time I actually changed the sample configs and generated all samples. All issues detected by the samples builds are resolved. New: @ParameterObject support (SpringDoc feature to support spring-data Pageable). |
…nstead of just "Swagger"
as reported by https://github.com/OpenAPITools/openapi-generator/runs/4866174156?check_suite_focus=true Can you please repeat step 3 to have the doc updated? Thanks. |
@wing328 I run export_docs_generators.sh and pushed the changes. |
@cachescrubber thanks again for the PR, which has been merged. When you've time next week, can you please PM me via Slack? https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM |
Hi. I'm trying to set, from Maven, |
This PR introduces two new additional properties for all Java Based
CodegenConfigs
(extendingAbstractJavaCodegen
). The Properties are defined by a new Features interface,org.openapitools.codegen.languages.features.DocumentationProviderFeatures
.Synopsis
--additional-properties documentationProvider=springdoc,annotationLibrary=swagger2
When a documentation provider and annotation library are selected, a boolean property is added to the codegen model. For example, when SpringDoc is the selected as a documentation provider, the following properties are available in the mustache templates.
The Documentation Provider and Annotation Libraries are defined in a dedicated Enum each.
The SpringCodegen serves as a demo of how to integrate into other Java based CodegenConfigs.
Naming is hard. The propertyNames and Annotation Values where not easy. Specially
Swagger1 and Swagger2 are based on the version numbers of their release artifacts, not using the target OAS specifiction version. Anyway, since the are defined in the Enums they are pretty easy to change in the current stage. Feel free to come up with suggestions and an alternative nameing.
Relates To
#8801
#9775
#11181
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(5.3.0),6.0.x