swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.37k stars 2.17k forks source link

set schema name for EnumTypes #4727

Open sam0r040 opened 1 month ago

sam0r040 commented 1 month ago

At Springwolf we use the parsed schemas to generate Examples. Thereby we use the field Schema.getName() for all schemas including enums.

When enumAsRef is used, the name of the enum is missing in its class schema. Also, when serialized, the name of a schema is ignored because of the @JsonIgnore annotation.

This PR adds the schema name for enums. We found the following comment: https://github.com/swagger-api/swagger-core/blob/5ee9cefe9455bf07d2671d9fd93fce2bd7c7b94f/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java#L379 And therefore believe that all enum classes should appear as models, resulting in the adaption of the tests.

Relates to #4722

micryc commented 2 weeks ago

Hi @sam0r040 could you share some details on how you used enumAsRef annotation ? I think it should work as intended