OpenAPITools / OpenAPITools/openapi-generator
openapi-generator-maven-plugin generate ascii with Description without escaping unsafe characters
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi,
i am using the openapi-generator-maven-plugin to generate Ascii from a json file.
My Json File has some special Formatations like \n for new lines in the descirption, but the Plugin deletes the Formatation.
I found a Function in the openapi-generator and i think thats the reason why my Formatation is deleted.
// remove \t, \n, \r
// replace \ with \\
// replace " with \"
// outer unescape to retain the original multi-byte characters
// finally escalate characters avoiding code injection
return escapeUnsafeCharacters(
StringEscapeUtils.unescapeJava(
StringEscapeUtils.escapeJava(input)
.replace("\\/", "/"))
.replaceAll("[\\t\\n\\r]", " ")
.replace("\\", "\\\\")
.replace("\"", "\\\""));
I am using the Plugin like this:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>openapi.json</inputSpec>
<generatorName>asciidoc</generatorName>
<skipValidateSpec>true</skipValidateSpec>
<configOptions>
<useIntroduction>true</useIntroduction>
<useMethodAndPath>true</useMethodAndPath>
<useTableTitles>true</useTableTitles>
</configOptions>
<output>output</output>
</configuration>
</execution>
</executions>
</plugin>
Is there a way to use the plugin with my Formatation?
Describe the solution you'd like
A Possibility to insert Formatations to the Descriptions
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
Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java, focusing on the escaping function shown in the issue. Reproduce the behavior with the openapi-generator-maven-plugin 5.3.1 and an OpenAPI JSON description containing formatting characters, then verify that generated AsciiDoc preserves the requested formatting without unsafe-character injection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100