4

my requirement is to use the properties names and types of the classes which are included in class path java objects.

Basically, $ref will allow us to use the classes which are included in class path like below

1) **YML File** 
paths:
  /users/{id}:
    parameters:
    - name: id
      in: path
      required: true
      description: the user identifier, as userId 
      schema:
        type: string
    get:
      responses:
        '200':
          description: the user being returned
          content:
            application/json:
              schema:
                $ref: "**TESTCALSSOFCLASSPATHORJAR**"
                properties:
                  uuid: # the unique user id
                    type: string
                    format: uuid

2) <plugin>
  <groupId>org.openapitools</groupId>
  <artifactId>openapi-generator-maven-plugin</artifactId>
  <version>${openapi-generator-maven-plugin.version}</version>
  <configuration>
      ... excluded for simplicity
      <importMappings>
          <importMapping>TESTCALSSOFCLASSPATHORJAR=path.to.your.TESTCALSSOFCLASSPATHORJAR</importMapping>        
      </importMappings>
  </configuration>
</plugin>

Is there any way that, I can refer id attribute name from my class path/jar java object??

paths:
  /users/{id}:
    parameters:
    - name: **id** -> I want to get this prop from TESTCALSSOFCLASSPATHORJAR class 
                      i.e.TESTCALSSOFCLASSPATHORJAR.id
      in: path
      required: true
      description: the user identifier, as userId 
      schema:
        type: string
    get:
      responses:
        '200':
          description: the user being returned
          content:
            application/json:
              schema:
                $ref: "**TESTCALSSOFCLASSPATHORJAR**"
                properties:
                  uuid: # the unique user id
                    type: string
                    format: uuid

Referred below documents and searching a lot but didn't find any solution.

https://github.com/OAI/OpenAPI-Specification https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin

Any suggestions would be really appreciated.

user3082107
  • 51
  • 1
  • 4
  • 1
    Could you take a look at the answer here https://stackoverflow.com/questions/59072297/openapi-generator-reference-an-external-pojo-in-yaml-file-specification ? – Faisal K Jan 07 '21 at 08:50

0 Answers0