Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1691
Something went wrong while setting issue due date.
Closed
Open
Issue created 6 years ago by Administrator@rootContributor
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

[BUG][Spring] generator not escaping backslashes

Open

[BUG][Spring] generator not escaping backslashes

Created by: hebra

Description

Trying to generate Java code from the Vimeo OpenAPI spec. That spec (api.yaml) uses backslashes in some of the strings (e.g. tag definitions). Using the openapi gradle plugin 3.3.4 the generator 'spring' with any of it libraries (spring-boot, spring-mvc, spring-cloud) generates code which does not escape backslashes properly.

openapi-generator version

3.3.4

OpenAPI declaration file content or url
{
	"generatorName": "spring",
	"library": "spring-boot",
	"groupId": "com.vimeo",
	"modelPackage": "com.vimeo.model",
	"apiPackage": "com.vimeo.api",
	"invokerPackage": "com.vimeo",
	"basePackage": "com.vimeo",
	"dateLibrary": "java8",
	"java8": true,
	"async": true,
	"responseWrapper": "ListenableFuture",
	"useBeanValidation": true
}
Command line used for generation

As this is a gradle project the command line is just

./gradlew clean openApiGenerate

but I'd assume the same code is generated when using the generator lib directly.

  • Language: Java 11
  • Gradle: 4.9
  • Libraries: Spring Boot 2.1 family
Steps to reproduce
  • create a new Spring Boot basic project (e.g. via http://start.spring.io/ in Java and Gradle flavour
  • add the Gradle OpenAPI plugin to build.gradle like this
buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.4"
  }
}

apply plugin: 'org.openapi.generator'
  • add a new openapi configuration file config.json
  • download the api.yaml from above Vimeo GitHub repo
  • add a openapi statement to the build.gradle like this (the folders might differ)
openApiGenerate {
	validateSpec = true
    configFile = "$rootDir/vimeo/config.json".toString()
    inputSpec = "$rootDir/vimeo/openapi/api.yaml".toString()
    outputDir = "$buildDir/generated".toString()
}
  • run ./gradlew clean openApiGenerate
  • open one of the generated java files, e.g. LanguagesAPI
  • check the tags annotation
tags={ "Videos\Languages", })

---> the backslash is not escaoped, leading to compile errors

Suggest a fix
  • it looks like a bug with the generator templates, as it works proper for other generators (like feign for Java). Fixing the template should fix the issue.
  1. Oh no!

    You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico.

    Incoming!

    Drop your designs to start your upload.
Tasks
0
server returned results with length 5, expected length of 9

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


Please register or sign in to reply
0 Assignees
None
Assign to
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
0
0 participants
Reference:

Menu

Explore Projects Groups Snippets