0

I am working on an endpoint implementation that wraps multiple endpoints.

There is an endpoint /entity1 implemented in a dependency with its own openapi spec generated in maven plugin to a certain package. And there is an endpoint /entity2 which comes from another dependency.

I am trying to generate a spec for /batch gets an array of entity1 and an array of entity2, like this schema:

paths:
  /batch:
    post:
      description: Batch ingest data
      operationId: batchCreate
      requestBody:
        content:
          application/json:          
            schema:
              $ref: '#/components/schemas/Batch'
        description: ...
components:
  schemas:
    Batch:
      type: object
      properties:
        entity1list:
          type: array
          items:
            type: object
        entity2list:
          type: array
          items:
            type: object

I currently have the model generated with java plain Object.

Questions:

  • Is it possible to point the openapi to a different spec loaded in a different package? That would be ideal. Keep in mind I can't import the spec and regenerate the code since it won't do it on different packages.
  • If not, can I convert the plain Object to Entity1/Entity2?
DanielM
  • 3,598
  • 5
  • 37
  • 53

1 Answers1

0

Solved using the post @Cristian referred to. While generating, it is possible to map certain references. Documentation here

<plugin>
  <groupId>org.openapitools</groupId>
  <artifactId>openapi-generator-maven-plugin</artifactId>
  <version>${openapi-generator-maven-plugin.version}</version>
  <configuration>
      ... excluded for simplicity
      <importMappings>
          <importMapping>SignatureNotification=path.to.your.SignatureNotification</importMapping>        
      </importMappings>
  </configuration>
</plugin>
DanielM
  • 3,598
  • 5
  • 37
  • 53