0

I have a swagger object, and everything is working great. I have now come to the point that I need to add something like:

components:
  schemas:
    MyObj:
      type: object
      properties:
        myExistingProperties.....
        newProperty:
          type: object
          $ref: my.sf.package.MyNewClass

My question is how can I reference a concrete object from swagger yml?

Thanks, Brian

Brian
  • 556
  • 6
  • 26
  • So if you down voted this question can you elaborate as to why you did not like the question? – Brian Jul 16 '20 at 13:51

1 Answers1

1

I found the answer here:

Swagger Codegen use existing class

in the yml

components:
  schemas:
    MyObj:
      type: object
      properties:
        myExistingProperties.....
        newProperty:
          $ref: '#/components/schemas/myNewobject'

in the pom:

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.2.2-SNAPSHOT</version>
    <executions>
        <execution>
            ...
            <configuration>
                ...
                <configOptions>
                   <import-mappings>MyNewClass=some.package.MyNewClass</import-mappings>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>
Brian
  • 556
  • 6
  • 26