EagleUmlCommon
EagleUmlCommon copied to clipboard
Translate YANG lists to swagger map with additionalProperties
How I'd like the translation to be like
When I define a list within a container, such as:
container virtualizers {
description "Container with multiple virtualizers";
list virtualizer {
key "id";
uses virtualizer;
}
}
(where virtualizer is a grouping with a leaf identifier called "id"), I'd like this to be translated as a Map/Dictionary Properties in swagger:
"virtualizers_schema": {
"description": "Container with multiple virtualizers",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/virtualizer"
}
}
Currently the translation is as follows:
"virtualizers_schema": {
"description": "List for multiple virtualizers",
"properties": {
"virtualizer": {
"items": {
"$ref": "#/definitions/virtualizer"
},
"type": "array",
"x-key": "id"
}
}
}
Why
The reason is because when I use swagger to generate the jaxrs code, and currently it creates the following class:
...
public class VirtualizersSchema {
@JsonProperty("virtualizer")
private List<Virtualizer> virtualizer = new ArrayList<Virtualizer>();
...
But since each virtualizer is uniquely identified by the "id" key, I'd prefer to have VirtualizersSchema as a HashMap (what you get when you translate the Map/Dictionary swagger file I proposed above):
...
public class VirtualizersSchema extends HashMap<String, Virtualizer> {
...
Do you think it's possible to provide a flag or something similar to the pyang plugin to perform this translation?