Closed tobyworks closed 6 months ago
Hi, you can overwrite the enums toString-method and use that as the values for the path parameters
enum class Animal(private val type: String) {
Dog("dog"), Cat("cat"), Mouse("mouse");
overwrite fun toString() = type
}
// add somewhere at startup (i.e. before/after installing swaggerui-plugin)
EncodingData.DEFAULT_SCHEMA_GENERATOR = SchemaGenerator(
schemaGeneratorConfigBuilder()
.with(Option.FLATTENED_ENUMS_FROM_TOSTRING) // use toString for enums
.build()
)
How does this work with 3.2.0?
Imagine i have a call where the path parameters can only be of a certain value for instance:
["dog", "cat", "mouse"]
Any other value is deemed invalid, so i would like to show those as available
pathParams
The only way i figured out to do it is to have a enum and pass that in as type, however it is not according to kotlin coding standards to create an enum like this:you would rather have it like this
But then the path param actually gets uppercased which also isn't what i want.