This repository was archived by the owner on Mar 16, 2025. It is now read-only.
2022.6
#102
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
annotation mapping
annotation mappings allows to add additional annotations to an OpenAPI source type.
(this originates from openapi-processor/openapi-processor-spring#143 advanced validation support, but has changed into a more general solution)
Currently, this is available as
global annotation type mapping:
it adds an annotation to the model class generated for the source type.
global & endpoint parameter annotation type mapping:
it adds an annotation to a parameter of the source type. Since a request body is passed as parameter the mapping will work for it too.
The global annotation mapping should be added to the
map/typesormap/parameterssection in the mapping.yaml.The endpoint (http method) mapping restricts the mapping to a specific endpoint. This will go to the
map/paths/<endpoint-path>/parameterssection in the mapping.yaml.The annotation type mapping is similar to other mappings and is defined like this:
Here is an examples
mapping.yamlthat defines additional annotations for two schemas (model classes)Foo&Bar:The
Sumannotation in the example is a custom bean validation but the feature itself is not limited to bean validation.<1> use
v2.1as the mapping version to avoid validation warnings in the mapping file.<2> the
Barmapping is using a global type annotation mapping, so the annotation is added to the generatedBarclass.<3> the
Foomapping adds the annotation to the parameter of the endpoint methods that useFoo.<4> this is a list of examples that shows annotation parameters.
The
Barannotation mapping will produce theBarmodel class with the additional annotation on the class:The
Fooannotation parameter mapping will produce the endpoint with the additional annotation on theFooparameter:The full example is available in the spring validation sample.
openapi-processor/openapi-processor-spring#144, use annotation for generated code instead of comment
the processor now generates a
@Generatedannotation and adds it to all generated interfaces and classes instead of the text header.Some tools recognize the
@Generatedannotation and exclude them from processing. For example, jacoco will automatically exclude the@Generatedfiles from the code coverage.this will look like this:
Because of the longish date the code formatter will probably add a few line breaks.
Generation of the data parameter can be disabled by setting the
generated-dateoption tofalse:<1> use
v2.1as the mapping version to avoid validation warnings in the mapping file.openapi-processor/openapi-processor-spring#140 additional parameter configuration did not working in global context
using an additional parameter in the global context was not implemented.
#99 windows path handling
was broken since 2022.5
This discussion was created from the release 2022.6.
Beta Was this translation helpful? Give feedback.
All reactions