spring-bootkotlingradleopenapiopenapi-generator

How to exclude specific endpoint from API generation


I've read topic Generate only one specific endpoint from API

But I have a bit different task I want to exclude some specifics endpoint from generation. Why do I need it? We have an experiment that analytics write open api schema and if they add new endpoint to existing controlller it leads to compile error(it require to implement new method in interface). We want to avoid this error without implementing stub.

Is there way to achieve it ?

I would apreciate example of gradle (build.gradle.kts)


Solution

  • So, according to the documentation you can simply add x-internal:true to the api path definition, and it will be skipped during generation.
    Try this for example:

    openapi: "3.0.0"
    info:
      version: 1.0.0
      title: Swagger Petstore
      license:
        name: MIT
    paths:
      /pets:
        get:
          # It will be generated
          summary: List all pets
          operationId: listPets
          ...
        post:
          # it will not
          x-internal: true
          summary: Create a pet
          operationId: createPets
          ...
    components:
      schemas:
       ...
    

    Just ask your analytics to add this by default when api is in draft phase.