Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude paths in Openapi code generation?

We are using a large third party API with many optional features. There are 27 endpoints and we need only a few of these from Maven. We are using server side generation.

If you are interested the API is here: https://github.com/mjeffrey/psd2 Ideally we would only generate and expose the ones we support.

Is it possible to just generate a list of API endpoints or exclude ones we don't want to support?

I see there is the possibility to generate only certain models but that is not what we need. the -D apis parameter seems tor be treated as a boolean in the source code.

https://github.com/OpenAPITools/openapi-generator#3---usage https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#selective-generation

I'm also considering a pre-processor so we don't need to manually edit the yaml file (which is updated regularly). Any suggestions for preprocessing the yaml file?

like image 919
MarkJ Avatar asked May 29 '26 20:05

MarkJ


1 Answers

The way to do this is to use the environment variable apis and provide a comma separated list of the root path-segment. Unfortunately in our case the root is /v1 so we get only one "api" generated and we can't select individual paths.

Stripping off the /v1 from all the paths we can then use:

Command line

java -Dapis="consents,{payment-service},accounts"

Maven

<configuration>
  <environmentVariables>
    <apis>consents,{payment-service},accounts</apis>
  </environmentVariables>
</configuration>
like image 164
MarkJ Avatar answered Jun 01 '26 20:06

MarkJ