1

I am trying to create a map object in swagger

definitions:
  foo:
   description: a sample class
   required: 
    - param
   properties:
    param:
     type: object
     description: this param is a map<String, Object> where object is a derivative of java.lang.object
     additionalproperties: 
       type: object

Swagger is generating the clent stub with the below code

public class foo  {
 private Map<String, Object> param = new HashMap<String, Object>();
 getters();
 setters();
}

but it is also generating a unused and unreferenced import statement

import io.swagger.model.Object;

I am trying to generate the client stub for jax-rs API using the below statement

java -jar "../swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" generate -i /../src/main/resources/swagger/swagger.yaml -l jaxrs -o sample

Please do tell me if I am doing it right to create a Map where Object is a reference to Java.lang class

  • Possible duplicate of [Why \`additionalProperties\` is the way to represent Dictionary/Map in Swagger/OpenAPI 2.0](https://stackoverflow.com/questions/41239913/why-additionalproperties-is-the-way-to-represent-dictionary-map-in-swagger-ope) – Naman Sep 12 '17 at 15:15

0 Answers0