Skip to content

[BUG][Java][Spring]allowUnicodeIdentifiers to false does not sanitize parameter names #1695

@jabby

Description

@jabby
Description

When allowUnicodeIdentifiers is set to true, the parameters name are not sanitize in the spring generated source code.

openapi-generator version

The openapi-generator version is the current master.

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

And the configuration 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

I tried allowUnicodeIdentifiers this weekend. I set it to true with the following openapi file.
It works as expected for interface. The parameter name use é character in the name.

default ResponseEntity<Void> sanitizeTagsGet(@ApiParam(value = "",required=true) @PathVariable("créance") String créance) {

When I set allowUnicodeIdentifiers to false, the result is the same. As I understand the parameter name should be sanitize.

default ResponseEntity<Void> sanitizeTagsGet(@ApiParam(value = "",required=true) @PathVariable("créance") String créance) {

For french language, it will be great to have the following result :

default ResponseEntity<Void> sanitizeTagsGet(@ApiParam(value = "",required=true) @PathVariable("créance") String creance) {

Related issues/PRs

Don't find any

Suggest a fix

I'm not sure if the problem comes from sanitize methods or in mustache templates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions