title: Springfox (swagger) - How to add dynamic attributs
body: <p>I am trying to add new attribut in swagger definition in my java spring project.
  I have read documentation and specially 
   <a href="https://springfox.github.io/springfox/docs/snapshot/#plugins" rel="nofollow noreferrer">https://springfox.github.io/springfox/docs/snapshot/#plugins</a></p>
  
  <p>But i was not able to add new attribute from scratch</p>
  
  <p>I am trying this code but it's not really what i want:</p>
  
  <pre><code>import java.util.HashMap;
  import java.util.Map;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.core.annotation.AnnotationUtils;
  import org.springframework.core.annotation.Order;
  import org.springframework.stereotype.Component;
  
  import com.fasterxml.classmate.ResolvedType;
  import com.fasterxml.classmate.TypeResolver;
  import com.google.common.base.Predicates;
  import fr.hop.springdatarest.demo.entity.City;
  import lombok.extern.java.Log;
  import springfox.documentation.builders.ModelPropertyBuilder;
  import springfox.documentation.builders.PathSelectors;
  import springfox.documentation.builders.RequestHandlerSelectors;
  import springfox.documentation.schema.Model;
  import springfox.documentation.schema.ModelProperty;
  import springfox.documentation.spi.DocumentationType;
  import springfox.documentation.spi.schema.ModelBuilderPlugin;
  import springfox.documentation.spi.schema.contexts.ModelContext;
  import springfox.documentation.spring.web.plugins.Docket;
  import springfox.documentation.swagger.common.SwaggerPluginSupport;
  
  @Log
  @Component
  @Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER + 1008)
  public class SwaggerDefinitionAddin implements ModelBuilderPlugin {
  
      @Autowired
      TypeResolver resolver;
  
      Map&lt;String, ModelProperty&gt; cityAddinMap = new HashMap&lt;String, ModelProperty&gt;();
  
      @Override
      public boolean supports(DocumentationType delimiter) {
          return DocumentationType.SWAGGER_2.equals(delimiter);
      }
  
      private Class&lt;?&gt; forClass(ModelContext context) {
          return resolver.resolve(context.getType()).getErasedType();
      }
  
      @Override
      public void apply(ModelContext modelContext) {
  
          if(forClass(modelContext) == City.class){
  
              modelContext.getBuilder().id("TEST").properties(????).build();
          }       
      }
  
  }
  </code></pre>
  
  <p>For exemple i have this definition:</p>
  
  <pre><code>"definitions": {
      "City": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "postalCode": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
  </code></pre>
  
  <p>And i want: </p>
  
  <pre><code>"definitions": {
      "City": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "postalCode": {
            "type": "integer",
            "format": "int32"
          },
          "meteo": {
            "$ref": "#/definitions/Meteo"
          }
        }
      },
  </code></pre>
  
  <p>Can you help me to add the meteo attribut in the definition ?
  In this case my goal is adding attribut programmatically without using annotation. </p>