Closed
Description
I would like to propose a new field called enumNames
.
Example:
definitions:
weather:
type: object
required:
- type
properties:
type:
type: integer
format: int32
enum:
- 1
- 2
- 3
enumNames:
- Sunny
- Cloudy
- Rainy
This information is necessary for generating the following Java enum.
public enum Weather {
Sunny(1),
Cloudy(2),
Rainy(3);
private final int type;
private Weather(final int type) {
this.type = type;
}
public type getType() {
return type;
}
}
Some web APIs require clients to send/retrieve integer enum items while knowing what they mean. So it is useful to be able to generate this kind of enum.
I had been seeking advice in the following swagger-codegen issue, and got a conclusion that we need a vendor extension (which corresponds to this proposal) using Swagger 2.0 spec.
swagger-api/swagger-codegen#2690
Metadata
Metadata
Assignees
Labels
No labels