shortQuestion
shortQuestion

Reputation: 493

How To ignore Endpoints from openapi.yaml in generation with openapi-generator-maven-plugin/

yaml and openapi-generator-maven-plugin is corretly generating Spring Boot Controller Interfaces from it. All is working fine. But now we want to overwrite one of the generated Interfaces with our own interface. How can we exclude a certain endpoint from this generation?

Example:

  paths:
  /currencies:
    get:
      tags:
        - DomainData
      summary: Lists all valid currencies available.
      operationId: "getCurrencies"
      parameters:
        - $ref: '#/components/parameters/AcceptLanguage'
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: string
                additionalProperties:
                  type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '5XX':
          $ref: '#/components/responses/Unexpected'

  /languages:
    get:
      tags:
        - DomainData
      summary: Lists all valid languages available.
      operationId: "getLanguages"
      parameters:
        - $ref: '#/components/parameters/AcceptLanguage'
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: string
                additionalProperties:
                  type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '5XX':
          $ref: '#/components/responses/Unexpected'

This is a part of the openapi.yaml and we would not like to generate for /languages but everything else.

Upvotes: 2

Views: 3262

Answers (1)

shortQuestion
shortQuestion

Reputation: 493

I found a solution we used a .openapi-generator-ignore and linked it in the pom options of the openapi generator.

In the .openapi-generator-ignore we used the full relative path from position of the ignore file to the file that is not existing and we don't want to get generated.

target/generated-sources/v1/src/main/java/ch/company/dsp/bff/project/generated/api/languageApi.java

Upvotes: 1

Related Questions