Skip to content

Conversation

@cbascom
Copy link
Contributor

@cbascom cbascom commented Mar 11, 2025

Closes #12215

The documentation for selective generation of APIs has been updated to specify the API names are the UpperCamelCase versions of the tags in the spec.

The documentation for use of operationIdNameMappings has been updated to specify that the operationIds have already been sanitized and converted to lowerCamelCase before they are compared with the specified operationIdNameMappings.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Mar 11, 2025

The documentation for use of operationIdNameMappings has been updated to specify that the operationIds have already been sanitized and converted to lowerCamelCase before they are compared with the specified operationIdNameMappings.

thanks for pointing it out.

i think that needs to be fixed. the mapping should be done using the original operationId provided in the spec (or auto-generated one if it's not defined)

update: filed #20846

@cbascom
Copy link
Contributor Author

cbascom commented Mar 12, 2025

Updated based on the fix in #20846.

To control the specific files being generated, you can pass a CSV list of what you want:
```sh
# generate the User and Pet APIs only
--global-property apis="User,Pet"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like depending on the generators, e.g. for python

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g python -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/python --global-property apis="user:pet"

(note that colon is used as a separator)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, it is actually a colon for all generators. The --global-property option accepts a comma separated list of key value pairs, so none of the key/value pairs can have a comma in them. After the split on the comma is done to separate out each key/value pair, CodegenConfigurator replaces the colon with a comma:

            configurator.addGlobalProperty(entry.getKey(), entry.getValue().replace(":", ","));

I was using a yaml config file with my actual schema I was generating at the time, so I never noticed I had it wrong since yaml doesn't have that issue.

At any rate, updated now to use the colon instead of the comma.

--global-property models=User,supportingFiles=StringUtil.java
```

The names of the apis are the _sanitized_ tags converted to _UpperCamelCase_ and are generated by the following steps:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we mention it's not always upper camel case and it really depends on the generators (e.g. python uses snake case) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to dig into this since I am still missing a piece somewhere apparently. Will try to take a look again this weekend.

The documentation for selective generation of APIs has been updated to
specify the API names are the sanitized UpperCamelCase versions of the
tags in the spec.

The sanitization rules have been documented in a separate section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] Documentation a detail about selective generation of apis

2 participants