openapi-processor / openapi-processor-core

moved into openapi-processor-base
Apache License 2.0
7 stars 5 forks source link

References from Generics of mapped types are not counted #91

Closed aburmeis closed 2 years ago

aburmeis commented 2 years ago

When you configure a type mapping in openapi-mapping.yaml using generics, the type reference is not counted and therefore the type will not be generated.

map:
    types:
        - type: MyResultPage => org.springframework.data.domain.Page<{package-name}.model.MyResult>

I see it would be hard to find such a reference, so either it should be possible to use OpenApi type names as generics:

map:
    types:
        - type: MyResultPage => org.springframework.data.domain.Page
           generics:
             - MyResult

or having an option to force generation of types to be configured:

force-types:
  - MyResult

I don't know which would be the best solution (would prefer the openapi type in generics) but somehow this has to be fixed/possible.

I am using openapi-processor-maven-plugin version 2021.1 with openapi-processor-spring version 2022.2.

hauner commented 2 years ago

That is strange, the first example should work. There is logic to handle it.

There are to 2 integration tests that use it. ... the tests have a different focus though. So it is possible that the {package-name} class get its used count from somewhere else.

I guess, I should create an explicit test for this case. Looking at it.

aburmeis commented 2 years ago

It seems the problem only exists if a suffix for model names is configured, sorry for confusion:

options:
  model-name-suffix: Dto
map:
  types:
      - type: MyResultPage => org.springframework.data.domain.Page<{package-name}.model.MyResultDto>
hauner commented 2 years ago

yes, suffix wasn't handled.

Thanks for reporting :-)

aburmeis commented 2 years ago

Much more thanks for fixing!

hauner commented 2 years ago

released in io.openapiprocessor:openapi-processor-spring:2022.3