Skip to content

Commit

Permalink
#251 Fix Parameter without description
Browse files Browse the repository at this point in the history
  • Loading branch information
jemacineiras committed Aug 8, 2023
1 parent 9fd41c7 commit a9d6a95
Show file tree
Hide file tree
Showing 34 changed files with 289 additions and 287 deletions.
2 changes: 1 addition & 1 deletion multiapi-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.sngular</groupId>
<artifactId>multiapi-engine</artifactId>
<version>4.9.6</version>
<version>4.9.7</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public interface ${className?cap_first}Api {
*/

@Operation(
operationId = "${operation.operationId}",<#if operation.summary?has_content>
summary = "${operation.summary}",</#if>
tags = {<#list operation.tags as tag>"${tag}"</#list>}<#if operation.responseObjects?has_content>,
responses = {
<#list operation.responseObjects as response> @ApiResponse(responseCode = "${response.responseName}", description = "${response.description}"<#if response.contentObjects?has_content>, content = @Content(<#list response.contentObjects as content>mediaType = "${content.name}", schema = @Schema(implementation = ${content.dataType?api.getClassString()}))</#list></#if>)<#if !response?is_last>,</#if>
operationId = "${operation.operationId}",<#if operation.summary?has_content>
summary = "${operation.summary}",</#if>
tags = {<#list operation.tags as tag>"${tag}"</#list>}<#if operation.responseObjects?has_content>,
responses = {
<#list operation.responseObjects as response> @ApiResponse(responseCode = "${response.responseName}", description = "${response.description}"<#if response.contentObjects?has_content>, content = @Content(<#list response.contentObjects as content>mediaType = "${content.name}", schema = @Schema(implementation = ${content.dataType?api.getClassString()}))</#list></#if>)<#if !response?is_last>,</#if>
</#list>
}</#if>
}</#if>
)
@RequestMapping(
method = RequestMethod.${operation.operationType},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@

import com.sngular.api.generator.plugin.exception.InvalidAPIException;
import com.sngular.api.generator.plugin.openapi.parameter.SpecFile;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

@Slf4j
class OpenApiGeneratorTest {

@TempDir(cleanup = CleanupMode.NEVER)
@TempDir
static Path baseDir;

private static OpenApiGenerator openApiGenerator;
Expand Down Expand Up @@ -109,6 +110,7 @@ static Stream<Arguments> fileSpecToProcess() {
@MethodSource("fileSpecToProcess")
void processFileSpec(final String type, final List<SpecFile> specFileList, final Function<Path, Boolean> validation) {
openApiGenerator.processFileSpec(specFileList);
log.debug(baseDir.toAbsolutePath().toString());
Assertions.assertThat(validation.apply(baseDir)).isTrue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public interface TestApi {
*/

@Operation(
operationId = "testAdditionalProperties",
summary = "testAdditionalProperties",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
operationId = "testAdditionalProperties",
summary = "testAdditionalProperties",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public interface TestApi {
*/

@Operation(
operationId = "testAdditionalProperties",
summary = "testAdditionalProperties",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
operationId = "testAdditionalProperties",
summary = "testAdditionalProperties",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public interface TestApi {
*/

@Operation(
operationId = "testAdditionalProperties",
summary = "testAdditionalProperties",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
operationId = "testAdditionalProperties",
summary = "testAdditionalProperties",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public interface GamesApi {
*/

@Operation(
operationId = "listGames",
summary = "List all available games",
tags = {"games"},
responses = {
@ApiResponse(responseCode = "200", description = "A paged array of games", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InlineResponse200ListGamesAnyOfDTO.class)))
}
operationId = "listGames",
summary = "List all available games",
tags = {"games"},
responses = {
@ApiResponse(responseCode = "200", description = "A paged array of games", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InlineResponse200ListGamesAnyOfDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public interface TestApi {
*/

@Operation(
operationId = "showTestById",
summary = "Info for a specific test",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "Expected response to a valid request", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiTestInfoDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorDTO.class)))
}
operationId = "showTestById",
summary = "Info for a specific test",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "Expected response to a valid request", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiTestInfoDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public interface TestSchemaApi {
*/

@Operation(
operationId = "listTest",
summary = "List all available test",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "A paged array of tests", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiTestDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorDTO.class)))
}
operationId = "listTest",
summary = "List all available test",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "A paged array of tests", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiTestDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiErrorDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public interface TestTagFirstApi {
*/

@Operation(
operationId = "listTestServer",
summary = "List all available testServer",
tags = {"TestTagFirst"},
responses = {
@ApiResponse(responseCode = "200", description = "A paged array of tests", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorDTO.class)))
}
operationId = "listTestServer",
summary = "List all available testServer",
tags = {"TestTagFirst"},
responses = {
@ApiResponse(responseCode = "200", description = "A paged array of tests", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public interface TestTagSecondApi {
*/

@Operation(
operationId = "showTestById",
summary = "Info for a specific test",
tags = {"TestTagSecond"},
responses = {
@ApiResponse(responseCode = "200", description = "Expected response to a valid request", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestInfoDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorDTO.class)))
}
operationId = "showTestById",
summary = "Info for a specific test",
tags = {"TestTagSecond"},
responses = {
@ApiResponse(responseCode = "200", description = "Expected response to a valid request", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestInfoDTO.class))),
@ApiResponse(responseCode = "default", description = "unexpected error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public interface TestApi {
*/

@Operation(
operationId = "testNoComponents",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "A string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)))
}
operationId = "testNoComponents",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "A string", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public interface SchemaMasterApi {
*/

@Operation(
operationId = "getSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
operationId = "getSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand All @@ -52,13 +52,13 @@ default ResponseEntity<SchemaDTO> getSchemaMaster(@Parameter(name = "subject", d
*/

@Operation(
operationId = "createSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
operationId = "createSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
)
@RequestMapping(
method = RequestMethod.POST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public interface SchemaMasterApi {
*/

@Operation(
operationId = "getSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiSchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
operationId = "getSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiSchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand All @@ -52,13 +52,13 @@ default ResponseEntity<ApiSchemaDTO> getSchemaMaster(@Parameter(name = "subject"
*/

@Operation(
operationId = "createSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiSchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
operationId = "createSchemaMaster",
tags = {"schemas"},
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiSchemaDTO.class))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Server Error")
}
)
@RequestMapping(
method = RequestMethod.POST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public interface TestApi {
*/

@Operation(
operationId = "testCreateDTO",
summary = "testCreateDTO",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
operationId = "testCreateDTO",
summary = "testCreateDTO",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with additional properties", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public interface TestApi {
*/

@Operation(
operationId = "testDateTime",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with date and date-time formats", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDateDTO.class)))
}
operationId = "testDateTime",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with date and date-time formats", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDateDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public interface TestApi {
*/

@Operation(
operationId = "testDateTime",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with date and date-time formats", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDateDTO.class)))
}
operationId = "testDateTime",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with date and date-time formats", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDateDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public interface TestApi {
*/

@Operation(
operationId = "testDateTime",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with date and date-time formats", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDateDTO.class)))
}
operationId = "testDateTime",
tags = {"test"},
responses = {
@ApiResponse(responseCode = "200", description = "An object with date and date-time formats", content = @Content(mediaType = "application/json", schema = @Schema(implementation = TestDateDTO.class)))
}
)
@RequestMapping(
method = RequestMethod.GET,
Expand Down
Loading

0 comments on commit a9d6a95

Please sign in to comment.