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
-
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/types
ormap/parameters
section 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>/parameters
section in the mapping.yaml.The annotation type mapping is similar to other mappings and is defined like this:
Here is an examples
mapping.yaml
that defines additional annotations for two schemas (model classes)Foo
&Bar
:The
Sum
annotation in the example is a custom bean validation but the feature itself is not limited to bean validation.<1> use
v2.1
as the mapping version to avoid validation warnings in the mapping file.<2> the
Bar
mapping is using a global type annotation mapping, so the annotation is added to the generatedBar
class.<3> the
Foo
mapping adds the annotation to the parameter of the endpoint methods that useFoo
.<4> this is a list of examples that shows annotation parameters.
The
Bar
annotation mapping will produce theBar
model class with the additional annotation on the class:The
Foo
annotation parameter mapping will produce the endpoint with the additional annotation on theFoo
parameter: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
@Generated
annotation and adds it to all generated interfaces and classes instead of the text header.Some tools recognize the
@Generated
annotation and exclude them from processing. For example, jacoco will automatically exclude the@Generated
files 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-date
option tofalse
:<1> use
v2.1
as 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