openapi-processor/openapi-processor-spring

Additional Annotations for String-Mapping

Snap252 opened this issue · 4 comments

Hi,
My Problem:
I have a type that comes from string:uuid (having a pattern in OpenAPI yaml file).
Now I want a type mapping from string:uuid => java.lang.String - first Problem is, that when I have an explicit mapping to any kind of inlined types (String, long, int,...) the pattern and min/max-annotations are gone -> fix this? Second is: for the case of string:uuid I want to have an extra annotation to this type
so resulting should be

class {
...
    @Pattern("given Pattern from OpenApi")
    @MyExtraAnnotationFromMappingFrile
    private String myMemberFromStringUUID;
...
}

The examples for combining type mapping plus annotation Mappings would be great

unfortunately this is a missing feature that seems obvious now.

the constraints are not used when there is a mapping. annotation mapping has the same problem, i.e. it doesn't work when there is a mapping.

I'm already working on it.

Thx for the feedback.

An additional improvement would be to add Annotations to all Elements, like:

....
map:
  types:
    - type: '* @ lombok.ToString'

ha, interesting idea.

The * may not be the best marker for this. With * I would expect it to add the annotation to any type which would include the simple types like strings & numbers. Maybe object @ ....

improved in 2023.1 (without the * notation) It will add the bean validation annotations to a mapped type.