openapi-processor / openapi-processor-spring

an OpenAPI 3.0 & 3.1 interface & model java code generator for Spring Boot
https://docs.openapiprocessor.io
Apache License 2.0
40 stars 9 forks source link

Additional Annotations for String-Mapping #151

Closed Snap252 closed 1 year ago

Snap252 commented 1 year ago

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

hauner commented 1 year ago

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.

Snap252 commented 1 year ago

Thx for the feedback.

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

....
map:
  types:
    - type: '* @ lombok.ToString'
hauner commented 1 year ago

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 @ ....

hauner commented 1 year ago

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