Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate YANG lists to swagger map with additionalProperties #231

Open
MartinPJorge opened this issue Apr 19, 2017 · 0 comments
Open

Translate YANG lists to swagger map with additionalProperties #231

MartinPJorge opened this issue Apr 19, 2017 · 0 comments
Labels
YangOpenApiTool Generates OpenAPI Spec (JSON) from UML XMI model files

Comments

@MartinPJorge
Copy link
Contributor

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?

@karthik-sethuraman karthik-sethuraman added the YangOpenApiTool Generates OpenAPI Spec (JSON) from UML XMI model files label Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
YangOpenApiTool Generates OpenAPI Spec (JSON) from UML XMI model files
Projects
None yet
Development

No branches or pull requests

2 participants