Reputation: 417
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?
Upvotes: 1
Views: 5446
Reputation: 97599
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
Upvotes: 2