问题
I'm working on an API where we define the API definition in the swagger.yaml file. The API which I am working on returns an output object which contains a map.
Output Object : OutputClass
public class OutputClass {
private Map<String, MapValue> map;
}
Right now, I used:
OutputClass:
type: object
additionalProperties:
$ref: '#/definitions/MapValue'
But Swagger Codegen generates the following Java code:
public class OutputClass extends HashMap<String, MapValue> implements Serializable {
}
Is there any way to achieve what I need?
回答1:
Your map definition is correct. There's an open issue with Swagger Codegen about the way it translates OpenAPI maps to Java code: https://github.com/swagger-api/swagger-codegen/issues/5187
来源:https://stackoverflow.com/questions/60256066/how-to-generate-mapstring-with-swagger-codegen