OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java][Spring] Sanitize tag name when use the option useTags is set to true
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The Api name is sanitize for the class name and for the value of @Api swagger tag. I think it should only be sanitized for the class name.
openapi-generator version
OpenAPI declaration file content or url
openapi: 3.0.1
info:
description: Sanitize for tags
version: 1.0.0
title: Sanitize for tags
paths:
'/sanitize-tags':
get:
summary: Check the class when generated with useTags option
tags:
- créances
parameters:
- name: créance
in: path
required: true
schema:
type: string
responses:
200:
$ref: '#/components/responses/201'
components:
responses:
200:
description: Get
Command line used for generation
Command line:
java -jar ~/git/github/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g spring -i tag.openapi.yaml -c java-config.json -o ./tags
Config file
{
"library": "spring-boot",
"groupId": "a.group.id",
"artifactId": "an-artifact-id",
"artifactVersion": "0.1.0-SNAPSHOT",
"sourceFolder": "src/main/java",
"configPackage": "my.api.config",
"modelPackage": "my.api.model",
"apiPackage": "my.api.resource",
"dateLibrary": "java8",
"useBeanValidation": true,
"interfaceOnly": true,
"implicitHeaders": true,
"swaggerDocketConfig": true,
"useTags": true,
"allowUnicodeIdentifiers": false
}
Steps to reproduce
Hello I started to test openapi-generator this weekend. I want to use useTags option in order to generate different classes for my API. I have some tags with unicode character like é in french language.
When I generate my spring-boot application, I discovered that the generated interface has the following name CrancesApi.
Here is a partial of the generated file.
@Validated
@Api(value = "Crances", description = "the Crances API")
public interface CrancesApi {
It will be great if the generated interface name will be CreanceApi and the value of @Api remains Créances.
If I set allowUnicodeIdentifiers to true, both are generated with Créances word.
Related issues/PRs
Maybe #1695 if the problem comes from sanitize methods
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied Spring generation command with tag.openapi.yaml and java-config.json, then compare the generated interface name with the @Api value. Trace where the tag is sanitized when useTags is enabled. Done means the interface is generated as CreanceApi while @Api retains Créances, without changing allowUnicodeIdentifiers behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100