Skip to content

Commit

Permalink
feature(openapi): Configure the openapi version only through the spri…
Browse files Browse the repository at this point in the history
…ng doc config.
  • Loading branch information
MichaelsJP committed Apr 26, 2023
1 parent 1def5ac commit 031b889
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.heigit.ors.api;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.SpecVersion;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
Expand All @@ -41,7 +40,7 @@ public class OpenApiConfiguration {

@Bean
public OpenAPI customOpenAPI(ServletContext servletContext) {
return new OpenAPI(SpecVersion.V31)
return new OpenAPI()
.servers(generateServers(servletContext))
.info(apiInfo());
}
Expand Down
2 changes: 1 addition & 1 deletion openrouteservice/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ springdoc.swagger-ui.syntaxHighlight.activated = true
#springdoc.packagesToScan=package1, package2
#springdoc.pathsToMatch=/ors/v2, /v2
springdoc.api-docs.path=/v2/api-docs
# springdoc.api-docs.version=openapi_3_1
springdoc.api-docs.version=OPENAPI_3_1
springdoc.swagger-ui.showExtensions = true
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ResultTest extends ServiceTest {
String expected_swagger_documentation_url = AppConfig.getGlobal().getParameter("info", "swagger_documentation_url");
SwaggerParseResult result;
OpenAPI openAPI;
String openAPIVersion = "3.1.0";

@BeforeEach
void setUp() {
Expand All @@ -51,7 +52,7 @@ void testGetSwagger() {
.get(getEndPointPath())
.then().log().ifValidationFails()
.assertThat()
.body("openapi", hasToString("3.0.1"))
.body("openapi", hasToString(openAPIVersion))
.statusCode(200);
}

Expand All @@ -66,14 +67,14 @@ void testSwaggerSpecValidationErrors() {

@Test
void testSwaggerVersion() {
assertEquals("3.0.1", openAPI.getOpenapi());
assertEquals(openAPIVersion, openAPI.getOpenapi());
}

@Test
void testSwaggerInfo() {
assertNotNull(openAPI.getInfo());
assertEquals("Openrouteservice", openAPI.getInfo().getTitle());
assertEquals("2", openAPI.getInfo().getVersion());
assertEquals("v2", openAPI.getInfo().getVersion());
}

@Test
Expand Down

0 comments on commit 031b889

Please sign in to comment.