OpenAPITools / OpenAPITools/openapi-generator

[BUG][spring] generate --api-name-suffix does not work for spring generator

Open
#8,822 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

4.3.1
and also reproduced on master

Additional:
os: macOS
os version: 11.2 (20D64)
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)

OpenAPI declaration file content or url

https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Generation Details

When I specify generate --api-name-suffix MySuffix (doc) and use spring generator I expect that the java interfaces in default api package org.openapitools.api will contain MySuffix in the names similar to --model-name-suffix parameter but for models. But I see just default Api suffix.

Actual:

ls ~/Documents/openapi-generated/spring/src/main/java/org/openapitools/api
ApiUtil.java
PetApi.java
PetApiController.java
StoreApi.java
StoreApiController.java
UserApi.java
UserApiController.java

Expected:

ApiUtil.java
PetMySuffix.java
PetMySuffixController.java
StoreMySuffix.java
StoreMySuffixController.java
UserMySuffix.java
UserMySuffixController.java
Steps to reproduce

Took master branch as in example or install 4.3.1 and run:

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
--api-name-suffix MySuffix \
-g spring \
-i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-o ~/Documents/openapi-generated/spring

then
ls ~/Documents/openapi-generated/spring/src/main/java/org/openapitools/api

Related issues/PRs

No similar opened issues. No similar closed issues for spring.
Something similar but for Dart https://github.com/OpenAPITools/openapi-generator/issues/5409 But let me emphasise that --model-name-suffix works well with spring.

Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the openapi-generator CLI entry point and the spring generator, using the petstore.yaml resource at modules/openapi-generator/src/test/resources/3_0/petstore.yaml. Run the documented generate command and compare the generated API filenames with the expected MySuffix names; done means the spring API interfaces and controllers include the configured suffix.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.