forked from loafle/openapi-generator-original
* spring: fix multiline tag description @Tag description should merge multiple lines into single line and trim the newline char at the end The fix was done in a similar way to what is done for operation description. * spring: multiline tag description add unit test --------- Co-authored-by: gonzalad <gonzalad@users.noreply.github.com> Co-authored-by: Oleh Kurpiak <oleh.kurpiak@gmail.com>
This commit is contained in:
@@ -858,7 +858,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
final String firstTagName = firstTag.getName();
|
||||
// But use a sensible tag name if there is none
|
||||
objs.put("tagName", "default".equals(firstTagName) ? firstOperation.baseName : firstTagName);
|
||||
objs.put("tagDescription", firstTag.getDescription());
|
||||
objs.put("tagDescription", escapeText(firstTag.getDescription()));
|
||||
}
|
||||
|
||||
return objs;
|
||||
|
||||
@@ -2666,4 +2666,30 @@ public class SpringCodegenTest {
|
||||
.bodyContainsLines("if (b.value.equals(value)) {");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void multiLineOperationDescription() throws IOException {
|
||||
Map<String, Object> additionalProperties = new HashMap<>();
|
||||
additionalProperties.put(SpringCodegen.USE_TAGS, "true");
|
||||
additionalProperties.put(DOCUMENTATION_PROVIDER, DocumentationProvider.SPRINGDOC.name());
|
||||
|
||||
Map<String, File> files = generateFromContract("src/test/resources/3_0/spring/issue12474-multiline-description.yaml", SPRING_BOOT, additionalProperties);
|
||||
|
||||
String expectedDescription = "# Multi-line descriptions This is an example of a multi-line description. It: - has multiple lines - uses Markdown (CommonMark) for rich text representation";
|
||||
JavaFileAssert.assertThat(files.get("PingTagApi.java"))
|
||||
.fileContains(expectedDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiLineTagDescription() throws IOException {
|
||||
Map<String, Object> additionalProperties = new HashMap<>();
|
||||
additionalProperties.put(SpringCodegen.USE_TAGS, "true");
|
||||
additionalProperties.put(DOCUMENTATION_PROVIDER, DocumentationProvider.SPRINGDOC.name());
|
||||
|
||||
Map<String, File> files = generateFromContract("src/test/resources/3_0/spring/issue12474-multiline-description.yaml", SPRING_BOOT, additionalProperties);
|
||||
|
||||
JavaFileAssert.assertThat(files.get("PingTagApi.java"))
|
||||
.fileContains("This is a multine tag : * tag item 1 * tag item 2 ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
openapi: "3.0.1"
|
||||
info:
|
||||
title: test
|
||||
version: "1.0"
|
||||
|
||||
tags:
|
||||
- name: pingTag
|
||||
description: |
|
||||
This is a multine tag :
|
||||
* tag item 1
|
||||
* tag item 2
|
||||
|
||||
paths:
|
||||
|
||||
/ping:
|
||||
get:
|
||||
tags:
|
||||
- pingTag
|
||||
summary: Multi-line descriptions
|
||||
description: |-
|
||||
# Multi-line descriptions
|
||||
|
||||
This is an example of a multi-line description.
|
||||
|
||||
It:
|
||||
- has multiple lines
|
||||
- uses Markdown (CommonMark) for rich text representation
|
||||
operationId: ping
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
Reference in New Issue
Block a user