Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Java][Spring] Sanitize tag name when use the option useTags is set to true #1696

Open
jabby opened this issue Dec 17, 2018 · 1 comment

Comments

@jabby
Copy link

jabby commented Dec 17, 2018

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
@auto-labeler
Copy link

auto-labeler bot commented Dec 17, 2018

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

sruehl pushed a commit to sruehl/openapi-generator that referenced this issue Dec 17, 2018
Fixes OpenAPITools#1696

An object schema containing no properties that also has additionalProperties
set to an object schema with no properties will cause
ModelUtils.isFreeFormObject to throw an NPE.
This PR adds additional checking to avoid the NPE.
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
Fixes OpenAPITools#1696

An object schema containing no properties that also has additionalProperties
set to an object schema with no properties will cause
ModelUtils.isFreeFormObject to throw an NPE.
This PR adds additional checking to avoid the NPE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant