Skip to content

[Java Spring] escaping of example for bean properties #5534

@kenjones-cisco

Description

@kenjones-cisco
Description

As part of change #5247 the approach for escaping the values associated with example from the API spec for a given attribute changed. The result is error: illegal escape character

Swagger-codegen version

master
regression from previous output

Swagger declaration file content or url
  app:
    title: Application
    type: object
    properties:
      id:
        title: App identity
        description: Unique identifier for an application
        type: string
        format: uuid
        example: 3377f6e7-dd55-4639-bc54-65646fde2adc
      name:
        title: App name
        description: Name for the application
        type: string
        example: Helloworld
      admin:
        title: App admins
        description: List of admins for the application
        type: array
        example: ["johndoe"]
        items:
          type: string
          example: johndoe
Command line used for generation

swagger-gen-cli generate -i ${API_FILE} --lang spring -c swagger_config.json

{
  "hideGenerationTimestamp": true,
  "dateLibrary": "java8",
  "useBeanValidation": true
}
Steps to reproduce

Run the command line above with the definition provided. The resulting example for the admin attribute will look like the following:

  /**
   * List of admins for the application
   *
   * @return admin
   */
  @ApiModelProperty(
    example = "[\"tdeckers\"]",
    value = "List of admins for the application"
  )
  @Valid
  public List<String> getAdmin() {
    return admin;
  }

When using https://github.com/google/google-java-format to format the entire code base.
I know get the error

App.java:179:35: error: illegal escape character
App.java:179:50: error: illegal escape character

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions