From e12388c568b5389924aff806878c8bfaf1ad20ec Mon Sep 17 00:00:00 2001 From: Julian Psotta Date: Mon, 27 Mar 2023 11:40:43 +0200 Subject: [PATCH] chore(api): Springfox to openapi migration --- openrouteservice/pom.xml | 7 +- .../heigit/ors/api/OpenApiConfiguration.java | 104 ++++++++++++ .../org/heigit/ors/api/SwaggerConfig.java | 110 ------------- .../ors/api/controllers/CentralityAPI.java | 77 +++++---- .../heigit/ors/api/controllers/ExportAPI.java | 82 ++++++---- .../ors/api/controllers/IsochronesAPI.java | 90 +++++++---- .../heigit/ors/api/controllers/MatrixAPI.java | 82 ++++++---- .../ors/api/controllers/RoutingAPI.java | 148 +++++++++++------- .../centrality/CentralityRequest.java | 15 +- .../ors/api/requests/common/APIEnums.java | 18 +-- .../ors/api/requests/common/APIRequest.java | 16 +- .../common/CoordinateListWrapper.java | 9 +- .../api/requests/common/RequestOptions.java | 17 +- .../api/requests/export/ExportRequest.java | 15 +- .../isochrones/IsochronesRequest.java | 51 +++--- .../api/requests/matrix/MatrixRequest.java | 35 +++-- .../requests/matrix/MatrixRequestOptions.java | 7 +- .../routing/RequestProfileParams.java | 9 +- .../RequestProfileParamsRestrictions.java | 29 ++-- .../RequestProfileParamsWeightings.java | 17 +- .../api/requests/routing/RouteRequest.java | 106 ++++++------- .../RouteRequestAlternativeRoutes.java | 11 +- .../requests/routing/RouteRequestOptions.java | 9 +- .../routing/RouteRequestRoundTripOptions.java | 11 +- .../json/JsonCentralityLocation.java | 8 +- .../json/JsonCentralityResponse.java | 6 +- .../centrality/json/JsonEdgeScore.java | 8 +- .../centrality/json/JsonNodeScore.java | 6 +- .../api/responses/export/json/JsonEdge.java | 8 +- .../responses/export/json/JsonEdgeExtra.java | 8 +- .../export/json/JsonExportResponse.java | 8 +- .../api/responses/export/json/JsonNode.java | 8 +- .../isochrones/IsochronesResponseInfo.java | 29 ++-- .../geojson/GeoJSONIsochroneBase.java | 8 +- .../geojson/GeoJSONIsochroneProperties.java | 17 +- .../geojson/GeoJSONIsochronesResponse.java | 6 +- .../responses/matrix/MatrixResponseInfo.java | 29 ++-- .../json/JSONIndividualMatrixResponse.java | 13 +- .../responses/matrix/json/JSONLocation.java | 11 +- .../matrix/json/JSONMatrixResponse.java | 7 +- .../responses/routing/RouteResponseInfo.java | 29 ++-- .../GeoJSONIndividualRouteResponse.java | 4 +- .../routing/geojson/GeoJSONRouteResponse.java | 4 +- .../routing/geojson/GeoJSONSummary.java | 6 +- .../routing/gpx/GPXRouteElement.java | 6 +- .../routing/gpx/GPXRouteResponse.java | 4 +- .../api/responses/routing/json/JSONExtra.java | 9 +- .../routing/json/JSONExtraSummary.java | 9 +- .../json/JSONIndividualRouteResponse.java | 27 ++-- .../api/responses/routing/json/JSONLeg.java | 41 +++-- .../responses/routing/json/JSONPtStop.java | 27 ++-- .../routing/json/JSONRouteResponse.java | 11 +- .../responses/routing/json/JSONSegment.java | 21 ++- .../api/responses/routing/json/JSONStep.java | 23 ++- .../routing/json/JSONStepManeuver.java | 13 +- .../responses/routing/json/JSONSummary.java | 14 +- .../responses/routing/json/JSONWarning.java | 10 +- .../src/main/resources/application.properties | 11 +- .../org/heigit/ors/api/util/SwaggerTest.java | 40 ++--- 59 files changed, 831 insertions(+), 733 deletions(-) create mode 100644 openrouteservice/src/main/java/org/heigit/ors/api/OpenApiConfiguration.java delete mode 100644 openrouteservice/src/main/java/org/heigit/ors/api/SwaggerConfig.java diff --git a/openrouteservice/pom.xml b/openrouteservice/pom.xml index c432e67ec5..175cbc1eb1 100644 --- a/openrouteservice/pom.xml +++ b/openrouteservice/pom.xml @@ -559,10 +559,11 @@ micrometer-registry-prometheus - io.springfox - springfox-swagger2 - 3.0.0 + org.springdoc + springdoc-openapi-ui + 1.6.15 + com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/OpenApiConfiguration.java b/openrouteservice/src/main/java/org/heigit/ors/api/OpenApiConfiguration.java new file mode 100644 index 0000000000..50986b8839 --- /dev/null +++ b/openrouteservice/src/main/java/org/heigit/ors/api/OpenApiConfiguration.java @@ -0,0 +1,104 @@ +/* + * This file is part of Openrouteservice. + * + * Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, see . + */ + +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; +import io.swagger.v3.oas.models.servers.Server; +import org.heigit.ors.config.AppConfig; +import org.springdoc.core.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.ServletContext; +import java.util.ArrayList; +import java.util.List; + +@Configuration +public class OpenApiConfiguration { + + private static final String SERVICE_NAME = "Openrouteservice"; + String swaggerDocumentationUrl = AppConfig.getGlobal().getParameter("info", "swagger_documentation_url"); + String swaggerDocumentationAddAutogeneratedUrl = AppConfig.getGlobal().getParameter("info", "swagger_documentation_add_autogenerated_url"); + + @Bean + public OpenAPI customOpenAPI(ServletContext servletContext) { + return new OpenAPI(SpecVersion.V31) + .servers(generateServers(servletContext)) + .info(apiInfo()); + } + + /** + * This gives a properly versioned swagger endpoint at api-docs/v2 for the ors v2 version. + * To introduce, e.g., v3 just use this function and replace v2 with v3. + */ + @Bean + public GroupedOpenApi orsV2ApiPath() { + String[] paths = {"/v2/**"}; + return GroupedOpenApi.builder().group("v2").pathsToMatch(paths) + .build(); + } + + /** + * This function provides the API v2 at the root api-docs/ path, as this was the old path of service the swagger. + * For proper API versioning see orsV2ApiPath(). + */ + @Bean + public GroupedOpenApi oldOrsV2ApiPath() { + String[] paths = {"/v2/**"}; + return GroupedOpenApi.builder().group("").pathsToMatch(paths) + .build(); + } + + private List generateServers(ServletContext servletContext) { + ArrayList listOfServers = new ArrayList<>(); + if (swaggerDocumentationUrl != null) { + Server customApi = new Server().url(swaggerDocumentationUrl).description("Custom server url"); + listOfServers.add(customApi); + } + if (Boolean.parseBoolean(swaggerDocumentationAddAutogeneratedUrl)) { + Server localhostServer = new Server().url(servletContext.getContextPath()).description("Auto generated server url"); + listOfServers.add(localhostServer); + } + return listOfServers; + } + + private Info apiInfo() { + return new Info() + .title(SERVICE_NAME) + .description("This is the openrouteservice API documentation") + .version("2") + .contact(apiContact()) + .license(apiLicence()); + } + + private License apiLicence() { + return new License() + .name("MIT Licence") + .url("https://opensource.org/licenses/mit-license.php"); + } + + private Contact apiContact() { + return new Contact() + .name(SERVICE_NAME) + .email("enquiry@openrouteservice.heigit.org") + .url("https://github.com/GIScience/openrouteservice"); + } +} + diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/SwaggerConfig.java b/openrouteservice/src/main/java/org/heigit/ors/api/SwaggerConfig.java deleted file mode 100644 index 6c4851c56a..0000000000 --- a/openrouteservice/src/main/java/org/heigit/ors/api/SwaggerConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This file is part of Openrouteservice. - * - * Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; - * if not, see . - */ - -package org.heigit.ors.api; - -import org.heigit.ors.config.AppConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.schema.ModelKey; -import springfox.documentation.schema.ModelSpecification; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.service.ModelNamesRegistry; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.ModelNamesRegistryFactoryPlugin; -import springfox.documentation.spi.service.contexts.ModelSpecificationRegistry; -import springfox.documentation.spring.web.paths.DefaultPathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.spring.web.scanners.DefaultModelNamesRegistryFactory; -import springfox.documentation.swagger.common.SwaggerPluginSupport; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.time.Duration; -import java.util.Collection; -import java.util.Set; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - String swagger_documentation_url = AppConfig.getGlobal().getParameter("info", "swagger_documentation_url"); - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("Openrouteservice") - .description("This is the openrouteservice API documentation") - .license("MIT") - .licenseUrl("https://github.com/swagger-api/swagger-ui/blob/master/LICENSE") - .contact(new Contact("", "", "enquiry@openrouteservice.heigit.org")) - .build(); - } - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .host(swagger_documentation_url) - .pathProvider(new DefaultPathProvider()) - .directModelSubstitute(Duration.class, String.class) - .select() - .apis(RequestHandlerSelectors.basePackage("org.heigit.ors.api")) - .paths(PathSelectors.any()) - .build() - .apiInfo(apiInfo()); - } - @Bean - @Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER) - public ModelNamesRegistryFactoryPlugin swaggerFixReqResPostfix() { - return new DefaultModelNamesRegistryFactory() { - @Override - public ModelNamesRegistry modelNamesRegistry(ModelSpecificationRegistry registry) { - return super.modelNamesRegistry(hackModelSpecificationRegistry(registry)); - } - - private ModelSpecificationRegistry hackModelSpecificationRegistry(ModelSpecificationRegistry delegate) { - return new ModelSpecificationRegistry() { - @Override - public ModelSpecification modelSpecificationFor(ModelKey key) { - return delegate.modelSpecificationFor(key); - } - - @Override - public boolean hasRequestResponsePairs(ModelKey test) { - return false; - } - - @Override - public Collection modelsDifferingOnlyInValidationGroups(ModelKey test) { - return delegate.modelsDifferingOnlyInValidationGroups(test); - } - - @Override - public Collection modelsWithSameNameAndDifferentNamespace(ModelKey test) { - return delegate.modelsWithSameNameAndDifferentNamespace(test); - } - - @Override - public Set modelKeys() { - return delegate.modelKeys(); - } - }; - } - - }; - } -} diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/CentralityAPI.java b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/CentralityAPI.java index a738f34e4c..2ba2afae2b 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/CentralityAPI.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/CentralityAPI.java @@ -19,7 +19,14 @@ import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import io.swagger.annotations.*; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler; import org.heigit.ors.api.requests.centrality.CentralityRequest; import org.heigit.ors.api.requests.common.APIEnums; @@ -27,6 +34,7 @@ import org.heigit.ors.centrality.CentralityErrorCodes; import org.heigit.ors.centrality.CentralityResult; import org.heigit.ors.exceptions.*; +import org.springdoc.core.annotations.RouterOperation; import org.springframework.core.convert.ConversionFailedException; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConversionException; @@ -37,64 +45,73 @@ import javax.servlet.http.HttpServletResponse; @RestController -@Api(value = "Centrality Service", tags = "Centrality") -@SwaggerDefinition(tags = { - @Tag(name = "Centrality", description = "Get node centrality for different modes of transport") +@OpenAPIDefinition(tags = { + @Tag(name = "Centrality Service", description = "Get node centrality for different modes of transport") }) @RequestMapping("/v2/centrality") -@ApiResponses({ - @ApiResponse(code = 400, message = "The request is incorrect and therefore can not be processed."), - @ApiResponse(code = 404, message = "An element could not be found. If possible, a more detailed error code is provided."), - @ApiResponse(code = 405, message = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation."), - @ApiResponse(code = 413, message = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit."), - @ApiResponse(code = 500, message = "An unexpected error was encountered and a more detailed error code is provided."), - @ApiResponse(code = 501, message = "Indicates that the server does not support the functionality needed to fulfill the request."), - @ApiResponse(code = 503, message = "The server is currently unavailable due to overload or maintenance.") -}) +@ApiResponse(responseCode = "400", description = "The request is incorrect and therefore can not be processed.") +@ApiResponse(responseCode = "404", description = "An element could not be found. If possible, a more detailed error code is provided.") +@ApiResponse(responseCode = "405", description = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation.") +@ApiResponse(responseCode = "413", description = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit.") +@ApiResponse(responseCode = "500", description = "An unexpected error was encountered and a more detailed error code is provided.") +@ApiResponse(responseCode = "501", description = "Indicates that the server does not support the functionality needed to fulfill the request.") +@ApiResponse(responseCode = "503", description = "The server is currently unavailable due to overload or maintenance.") public class CentralityAPI { static final CommonResponseEntityExceptionHandler errorHandler = new CommonResponseEntityExceptionHandler(CentralityErrorCodes.BASE); // generic catch methods - when extra info is provided in the url, the other methods are accessed. @GetMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getGetMapping() throws MissingParameterException { throw new MissingParameterException(CentralityErrorCodes.MISSING_PARAMETER, "profile"); } @PostMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public String getPostMapping(@RequestBody CentralityRequest request) throws MissingParameterException { throw new MissingParameterException(CentralityErrorCodes.MISSING_PARAMETER, "profile"); } // Matches any response type that has not been defined @PostMapping(value = "/{profile}/*") - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getInvalidResponseType() throws StatusCodeException { throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, CentralityErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "This response format is not supported"); } // Functional request methods @PostMapping(value = "/{profile}") - @ApiOperation(notes = "Returns an ordered list of points and centrality values within a given bounding box for a selected profile and its settings as JSON", value = "Centrality Service (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses( - @ApiResponse(code = 200, - message = "Standard response for successfully processed requests. Returns JSON.", //TODO: add docs - response = JsonCentralityResponse.class) - ) - public JsonCentralityResponse getDefault(@ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody CentralityRequest request) throws StatusCodeException { + @RouterOperation(operation = @Operation(description = "Returns an ordered list of points and centrality values within a given bounding box for a selected profile and its settings as JSON.", summary = "Centrality Service (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns JSON.", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = JsonCentralityResponse.class)) + ) + }) + public JsonCentralityResponse getDefault(@Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody CentralityRequest request) throws StatusCodeException { return getJsonCentrality(profile, request); } @PostMapping(value = "/{profile}/json", produces = {"application/json;charset=UTF-8"}) - @ApiOperation(notes = "Returns an ordered list of points and centrality values within a given bounding box for a selected profile and its settings as JSON", value = "Centrality Service JSON (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "JSON Response", response = JsonCentralityResponse.class) - }) + @RouterOperation(operation = @Operation(description = "Returns an ordered list of points and centrality values within a given bounding box for a selected profile and its settings as JSON.", summary = "Centrality Service JSON (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json") + @ApiResponse(responseCode = "200", + description = "JSON Response.", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = JsonCentralityResponse.class)) + ) + }) public JsonCentralityResponse getJsonCentrality( - @ApiParam(value = "Specifies the profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody CentralityRequest request) throws StatusCodeException { + @Parameter(description = "Specifies the profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody CentralityRequest request) throws StatusCodeException { request.setProfile(profile); request.setResponseType(APIEnums.CentralityResponseType.JSON); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java index d7630e036b..e7f79b53a9 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/ExportAPI.java @@ -19,14 +19,22 @@ import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import io.swagger.annotations.*; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler; -import org.heigit.ors.api.requests.export.ExportRequest; import org.heigit.ors.api.requests.common.APIEnums; +import org.heigit.ors.api.requests.export.ExportRequest; import org.heigit.ors.api.responses.export.json.JsonExportResponse; +import org.heigit.ors.exceptions.*; import org.heigit.ors.export.ExportErrorCodes; import org.heigit.ors.export.ExportResult; -import org.heigit.ors.exceptions.*; +import org.springdoc.core.annotations.RouterOperation; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConversionException; import org.springframework.http.converter.HttpMessageNotReadableException; @@ -36,61 +44,75 @@ import javax.servlet.http.HttpServletResponse; @RestController -@Api(value = "Export Service", description = "Export the base graph for different modes of transport", tags = "Export") -@RequestMapping("/v2/export") -@ApiResponses({ - @ApiResponse(code = 400, message = "The request is incorrect and therefore can not be processed."), - @ApiResponse(code = 404, message = "An element could not be found. If possible, a more detailed error code is provided."), - @ApiResponse(code = 405, message = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation."), - @ApiResponse(code = 413, message = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit."), - @ApiResponse(code = 500, message = "An unexpected error was encountered and a more detailed error code is provided."), - @ApiResponse(code = 501, message = "Indicates that the server does not support the functionality needed to fulfill the request."), - @ApiResponse(code = 503, message = "The server is currently unavailable due to overload or maintenance.") +@OpenAPIDefinition(tags = { + @Tag(name = "Export Service", description = "Export the base graph for different modes of transport") }) +@RequestMapping("/v2/export") + +@ApiResponse(responseCode = "400", description = "The request is incorrect and therefore can not be processed.") +@ApiResponse(responseCode = "404", description = "An element could not be found. If possible, a more detailed error code is provided.") +@ApiResponse(responseCode = "405", description = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation.") +@ApiResponse(responseCode = "413", description = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit.") +@ApiResponse(responseCode = "500", description = "An unexpected error was encountered and a more detailed error code is provided.") +@ApiResponse(responseCode = "501", description = "Indicates that the server does not support the functionality needed to fulfill the request.") +@ApiResponse(responseCode = "503", description = "The server is currently unavailable due to overload or maintenance.") public class ExportAPI { static final CommonResponseEntityExceptionHandler errorHandler = new CommonResponseEntityExceptionHandler(ExportErrorCodes.BASE); // generic catch methods - when extra info is provided in the url, the other methods are accessed. @GetMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getGetMapping() throws MissingParameterException { throw new MissingParameterException(ExportErrorCodes.MISSING_PARAMETER, "profile"); } @PostMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public String getPostMapping(@RequestBody ExportRequest request) throws MissingParameterException { throw new MissingParameterException(ExportErrorCodes.MISSING_PARAMETER, "profile"); } // Matches any response type that has not been defined @PostMapping(value="/{profile}/*") - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getInvalidResponseType() throws StatusCodeException { throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "This response format is not supported"); } // Functional request methods @PostMapping(value = "/{profile}") - @ApiOperation(notes = "Returns a list of points, edges and weights within a given bounding box for a selected profile as JSON", value = "Export Service (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses( - @ApiResponse(code = 200, - message = "Standard response for successfully processed requests. Returns JSON.", //TODO: add docs - response = JsonExportResponse.class) - ) - public JsonExportResponse getDefault(@ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody ExportRequest request) throws StatusCodeException { + @RouterOperation(operation = @Operation(description = "Returns a list of points, edges and weights within a given bounding box for a selected profile as JSON. " + + "This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.", summary = "Directions Service (GET)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns JSON.", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = JsonExportResponse.class)) + ) + }) + public JsonExportResponse getDefault(@Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody ExportRequest request) throws StatusCodeException { return getJsonExport(profile, request); } @PostMapping(value = "/{profile}/json", produces = {"application/json;charset=UTF-8"}) - @ApiOperation(notes = "Returns a list of points, edges and weights within a given bounding box for a selected profile JSON", value = "Export Service JSON (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "JSON Response", response = JsonExportResponse.class) - }) + @RouterOperation(operation = @Operation(description = "Returns a list of points, edges and weights within a given bounding box for a selected profile JSON.", summary = "Export Service JSON (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json") + @ApiResponse(responseCode = "200", + description = "JSON Response.", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = JsonExportResponse.class)) + ) + }) public JsonExportResponse getJsonExport( - @ApiParam(value = "Specifies the profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody ExportRequest request) throws StatusCodeException { + @Parameter(description = "Specifies the profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody ExportRequest request) throws StatusCodeException { request.setProfile(profile); request.setResponseType(APIEnums.CentralityResponseType.JSON); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/IsochronesAPI.java b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/IsochronesAPI.java index 7908c8c0f5..6e44e08974 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/IsochronesAPI.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/IsochronesAPI.java @@ -20,7 +20,14 @@ import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import io.swagger.annotations.*; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.isochrones.IsochronesRequest; @@ -28,6 +35,7 @@ import org.heigit.ors.exceptions.*; import org.heigit.ors.isochrones.IsochroneMapCollection; import org.heigit.ors.isochrones.IsochronesErrorCodes; +import org.springdoc.core.annotations.RouterOperation; import org.springframework.core.convert.ConversionFailedException; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConversionException; @@ -38,69 +46,83 @@ import javax.servlet.http.HttpServletResponse; @RestController -@Api(value = "Isochrones Service", tags = "Isochrones") -@SwaggerDefinition(tags = { - @Tag(name = "Isochrones", description = "Obtain areas of reachability from given locations") +@OpenAPIDefinition(tags = { + @Tag(name = "Isochrones Service", description = "Obtain areas of reachability from given locations") }) @RequestMapping("/v2/isochrones") -@ApiResponses({ - @ApiResponse(code = 400, message = "The request is incorrect and therefore can not be processed."), - @ApiResponse(code = 404, message = "An element could not be found. If possible, a more detailed error code is provided."), - @ApiResponse(code = 405, message = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation."), - @ApiResponse(code = 413, message = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit."), - @ApiResponse(code = 500, message = "An unexpected error was encountered and a more detailed error code is provided."), - @ApiResponse(code = 501, message = "Indicates that the server does not support the functionality needed to fulfill the request."), - @ApiResponse(code = 503, message = "The server is currently unavailable due to overload or maintenance.") -}) + +@ApiResponse(responseCode = "400", description = "The request is incorrect and therefore can not be processed.") +@ApiResponse(responseCode = "404", description = "An element could not be found. If possible, a more detailed error code is provided.") +@ApiResponse(responseCode = "405", description = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation.") +@ApiResponse(responseCode = "413", description = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit.") +@ApiResponse(responseCode = "500", description = "An unexpected error was encountered and a more detailed error code is provided.") +@ApiResponse(responseCode = "501", description = "Indicates that the server does not support the functionality needed to fulfill the request.") +@ApiResponse(responseCode = "503", description = "The server is currently unavailable due to overload or maintenance.") public class IsochronesAPI { static final CommonResponseEntityExceptionHandler errorHandler = new CommonResponseEntityExceptionHandler(IsochronesErrorCodes.BASE); // generic catch methods - when extra info is provided in the url, the other methods are accessed. @GetMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getGetMapping() throws MissingParameterException { throw new MissingParameterException(IsochronesErrorCodes.MISSING_PARAMETER, "profile"); } @PostMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public String getPostMapping(@RequestBody IsochronesRequest request) throws MissingParameterException { throw new MissingParameterException(IsochronesErrorCodes.MISSING_PARAMETER, "profile"); } // Matches any response type that has not been defined @PostMapping(value = "/{profile}/*") - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getInvalidResponseType() throws StatusCodeException { throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, IsochronesErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "This response format is not supported"); } // Functional request methods @PostMapping(value = "/{profile}", produces = "application/geo+json;charset=UTF-8") - @ApiOperation(value = "Isochrones Service", notes = "The Isochrone Service supports time and distance analyses for one single or multiple locations.\n" + - "You may also specify the isochrone interval or provide multiple exact isochrone range values.\n" + - "This service allows the same range of profile options as the /directions endpoint,\n" + - "which help you to further customize your request to obtain a more detailed reachability area response.", httpMethod = "POST", consumes = "application/geo+json") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Standard response for successfully processed requests. Returns GeoJSON.", response = GeoJSONIsochronesResponse.class) - }) + @RouterOperation(operation = @Operation(description = """ + The Isochrone Service supports time and distance analyses for one single or multiple locations. + "You may also specify the isochrone interval or provide multiple exact isochrone range values. + "This service allows the same range of profile options as the /directions endpoint, + "which help you to further customize your request to obtain a more detailed reachability area response.""", summary = "Isochrones Service"), + method = RequestMethod.POST, + consumes = "application/geo+json", + produces = "application/geo+json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns GeoJSON.", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = GeoJSONIsochronesResponse.class)) + ) + }) public GeoJSONIsochronesResponse getDefaultIsochrones( - @ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody IsochronesRequest request) throws Exception { + @Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody IsochronesRequest request) throws Exception { return getGeoJsonIsochrones(profile, request); } @PostMapping(value = "/{profile}/geojson", produces = "application/geo+json;charset=UTF-8") - @ApiOperation(value = "The Isochrone Service supports time and distance analyses for one single or multiple locations.\n" + - "You may also specify the isochrone interval or provide multiple exact isochrone range values.\n" + - "This service allows the same range of profile options as the /directions endpoint,\n" + - "which help you to further customize your request to obtain a more detailed reachability area response.", httpMethod = "POST", consumes = "application/geo+json", hidden = true) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Standard response for successfully processed requests. Returns GeoJSON.", response = GeoJSONIsochronesResponse.class) - }) + @RouterOperation(operation = @Operation(description =""" + The Isochrone Service supports time and distance analyses for one single or multiple locations. + "You may also specify the isochrone interval or provide multiple exact isochrone range values. + "This service allows the same range of profile options as the /directions endpoint, + "which help you to further customize your request to obtain a more detailed reachability area response.""", summary = "Isochrones Service", hidden = true), + method = RequestMethod.POST, + consumes = "application/geo+json", + produces = "application/geo+json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns GeoJSON.", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = GeoJSONIsochronesResponse.class)) + ) + }) public GeoJSONIsochronesResponse getGeoJsonIsochrones( - @ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody IsochronesRequest request) throws Exception { + @Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody IsochronesRequest request) throws Exception { request.setProfile(profile); request.setResponseType(APIEnums.RouteResponseType.GEOJSON); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/MatrixAPI.java b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/MatrixAPI.java index ffe7fea2c5..3a24d33ed7 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/MatrixAPI.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/MatrixAPI.java @@ -19,7 +19,14 @@ import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import io.swagger.annotations.*; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.matrix.MatrixRequest; @@ -27,6 +34,7 @@ import org.heigit.ors.exceptions.*; import org.heigit.ors.matrix.MatrixErrorCodes; import org.heigit.ors.matrix.MatrixResult; +import org.springdoc.core.annotations.RouterOperation; import org.springframework.core.convert.ConversionFailedException; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConversionException; @@ -37,39 +45,37 @@ import javax.servlet.http.HttpServletResponse; @RestController -@Api(value = "Matrix Service", tags = "Matrix") -@SwaggerDefinition(tags = { - @Tag(name = "Matrix", description = "Obtain one-to-many, many-to-one and many-to-many matrices for time and distance") -}) +@OpenAPIDefinition( + tags = { + @Tag(name = "Matrix Service", description = "Obtain one-to-many, many-to-one and many-to-many matrices for time and distance") + }) @RequestMapping("/v2/matrix") -@ApiResponses({ - @ApiResponse(code = 400, message = "The request is incorrect and therefore can not be processed."), - @ApiResponse(code = 404, message = "An element could not be found. If possible, a more detailed error code is provided."), - @ApiResponse(code = 405, message = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation."), - @ApiResponse(code = 413, message = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit."), - @ApiResponse(code = 500, message = "An unexpected error was encountered and a more detailed error code is provided."), - @ApiResponse(code = 501, message = "Indicates that the server does not support the functionality needed to fulfill the request."), - @ApiResponse(code = 503, message = "The server is currently unavailable due to overload or maintenance.") -}) +@ApiResponse(responseCode = "400", description = "The request is incorrect and therefore can not be processed.") +@ApiResponse(responseCode = "404", description = "An element could not be found. If possible, a more detailed error code is provided.") +@ApiResponse(responseCode = "405", description = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation.") +@ApiResponse(responseCode = "413", description = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit.") +@ApiResponse(responseCode = "500", description = "An unexpected error was encountered and a more detailed error code is provided.") +@ApiResponse(responseCode = "501", description = "Indicates that the server does not support the functionality needed to fulfill the request.") +@ApiResponse(responseCode = "503", description = "The server is currently unavailable due to overload or maintenance.") public class MatrixAPI { static final CommonResponseEntityExceptionHandler errorHandler = new CommonResponseEntityExceptionHandler(MatrixErrorCodes.BASE); // generic catch methods - when extra info is provided in the url, the other methods are accessed. @GetMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getGetMapping() throws MissingParameterException { throw new MissingParameterException(MatrixErrorCodes.MISSING_PARAMETER, "profile"); } @PostMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public String getPostMapping() throws MissingParameterException { throw new MissingParameterException(MatrixErrorCodes.MISSING_PARAMETER, "profile"); } // Matches any response type that has not been defined @PostMapping(value = "/{profile}/*") - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getInvalidResponseType() throws StatusCodeException { throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, MatrixErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "This response format is not supported"); } @@ -77,24 +83,40 @@ public void getInvalidResponseType() throws StatusCodeException { // Functional request methods @PostMapping(value = "/{profile}", produces = {"application/json;charset=UTF-8"}) - @ApiOperation(value = "Matrix Service", notes = "Returns duration or distance matrix for multiple source and destination points.\n" + - "By default a square duration matrix is returned where every point in locations is paired with each other. The result is null if a value can’t be determined.", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Standard response for successfully processed requests. Returns JSON.", response = JSONMatrixResponse.class) - }) - public JSONMatrixResponse getDefault(@ApiParam(value = "Specifies the matrix profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody MatrixRequest request) throws StatusCodeException { + @RouterOperation(operation = @Operation(description = "Returns duration or distance matrix for multiple source and destination points.\n" + + "By default a square duration matrix is returned where every point in locations is paired with each other. The result is null if a value can’t be determined.", + summary = "Matrix Service"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json;charset=UTF-8") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns JSON.", + content = {@Content( + mediaType = "application/json;charset=UTF-8", + array = @ArraySchema(schema = @Schema(implementation = JSONMatrixResponse.class)) + ) + }) + public JSONMatrixResponse getDefault(@Parameter(name = "profile", description = "Specifies the matrix profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody MatrixRequest request) throws StatusCodeException { return getJsonMime(profile, request); } @PostMapping(value = "/{profile}/json", produces = {"application/json;charset=UTF-8"}) - @ApiOperation(value = "Get a matrix calculation from the specified profile", httpMethod = "POST", consumes = "application/json", hidden = true) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Standard response for successfully processed requests. Returns JSON.", response = JSONMatrixResponse.class) - }) + @RouterOperation(operation = @Operation( + summary = "Get a matrix calculation from the specified profile",hidden = true), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json;charset=UTF-8") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns JSON.", + content = {@Content( + mediaType = "application/json;charset=UTF-8", + array = @ArraySchema(schema = @Schema(implementation = JSONMatrixResponse.class)) + ) + }) public JSONMatrixResponse getJsonMime( - @ApiParam(value = "Specifies the matrix profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody MatrixRequest originalRequest) throws StatusCodeException { + @Parameter(description = "Specifies the matrix profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody MatrixRequest originalRequest) throws StatusCodeException { originalRequest.setProfile(profile); originalRequest.setResponseType(APIEnums.MatrixResponseType.JSON); MatrixResult matrixResult = originalRequest.generateMatrixFromRequest(); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/RoutingAPI.java b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/RoutingAPI.java index af8f106bc9..12f346f082 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/controllers/RoutingAPI.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/controllers/RoutingAPI.java @@ -19,7 +19,14 @@ import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; -import io.swagger.annotations.*; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; import org.heigit.ors.api.errors.CommonResponseEntityExceptionHandler; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.routing.RouteRequest; @@ -30,6 +37,7 @@ import org.heigit.ors.routing.RouteResult; import org.heigit.ors.routing.RoutingErrorCodes; import org.locationtech.jts.geom.Coordinate; +import org.springdoc.core.annotations.RouterOperation; import org.springframework.core.convert.ConversionFailedException; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageConversionException; @@ -40,39 +48,37 @@ import javax.servlet.http.HttpServletResponse; @RestController -@Api(value = "Directions Service", tags = "Directions") -@SwaggerDefinition(tags = { - @Tag(name = "Directions", description = "Get directions for different modes of transport") +@OpenAPIDefinition(tags = { + @Tag(name = "Directions Service", description = "Get directions for different modes of transport") }) @RequestMapping("/v2/directions") -@ApiResponses({ - @ApiResponse(code = 400, message = "The request is incorrect and therefore can not be processed."), - @ApiResponse(code = 404, message = "An element could not be found. If possible, a more detailed error code is provided."), - @ApiResponse(code = 405, message = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation."), - @ApiResponse(code = 413, message = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit."), - @ApiResponse(code = 500, message = "An unexpected error was encountered and a more detailed error code is provided."), - @ApiResponse(code = 501, message = "Indicates that the server does not support the functionality needed to fulfill the request."), - @ApiResponse(code = 503, message = "The server is currently unavailable due to overload or maintenance.") -}) + +@ApiResponse(responseCode = "400", description = "The request is incorrect and therefore can not be processed.") +@ApiResponse(responseCode = "404", description = "An element could not be found. If possible, a more detailed error code is provided.") +@ApiResponse(responseCode = "405", description = "The specified HTTP method is not supported. For more details, refer to the EndPoint documentation.") +@ApiResponse(responseCode = "413", description = "The request is larger than the server is able to process, the data provided in the request exceeds the capacity limit.") +@ApiResponse(responseCode = "500", description = "An unexpected error was encountered and a more detailed error code is provided.") +@ApiResponse(responseCode = "501", description = "Indicates that the server does not support the functionality needed to fulfill the request.") +@ApiResponse(responseCode = "503", description = "The server is currently unavailable due to overload or maintenance.") public class RoutingAPI { static final CommonResponseEntityExceptionHandler errorHandler = new CommonResponseEntityExceptionHandler(RoutingErrorCodes.BASE); // generic catch methods - when extra info is provided in the url, the other methods are accessed. @GetMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getGetMapping() throws MissingParameterException { throw new MissingParameterException(RoutingErrorCodes.MISSING_PARAMETER, "profile"); } @PostMapping - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public String getPostMapping(@RequestBody RouteRequest request) throws MissingParameterException { throw new MissingParameterException(RoutingErrorCodes.MISSING_PARAMETER, "profile"); } // Matches any response type that has not been defined @PostMapping(value = "/{profile}/*") - @ApiOperation(value = "", hidden = true) + @Operation(summary = "", hidden = true) public void getInvalidResponseType() throws StatusCodeException { throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, RoutingErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "This response format is not supported"); } @@ -80,16 +86,21 @@ public void getInvalidResponseType() throws StatusCodeException { // Functional request methods @GetMapping(value = "/{profile}", produces = {"application/geo+json;charset=UTF-8"}) - @ApiOperation(notes = "Get a basic route between two points with the profile provided. Returned response is in GeoJSON format. " + - "This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.", value = "Directions Service (GET)", httpMethod = "GET") - @ApiResponses( - @ApiResponse(code = 200, - message = "Standard response for successfully processed requests. Returns GeoJSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).", - response = GeoJSONRouteResponse.class) - ) - public GeoJSONRouteResponse getSimpleGeoJsonRoute(@ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "Start coordinate of the route in `longitude,latitude` format.", required = true, example = "8.681495,49.41461") @RequestParam Coordinate start, - @ApiParam(value = "Destination coordinate of the route in `longitude,latitude` format.", required = true, example = "8.687872,49.420318") @RequestParam Coordinate end) throws StatusCodeException { + @RouterOperation(operation = @Operation(description = "Get a basic route between two points with the profile provided. Returned response is in GeoJSON format. " + + "This method does not accept any request body or parameters other than profile, start coordinate, and end coordinate.", summary = "Directions Service (GET)"), + method = RequestMethod.GET, + consumes = "application/json", + produces = "application/geo+json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns GeoJSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = GeoJSONRouteResponse.class)) + ) + }) + public GeoJSONRouteResponse getSimpleGeoJsonRoute(@Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "Start coordinate of the route in `longitude,latitude` format.", required = true, example = "8.681495,49.41461") @RequestParam Coordinate start, + @Parameter(description = "Destination coordinate of the route in `longitude,latitude` format.", required = true, example = "8.687872,49.420318") @RequestParam Coordinate end) throws StatusCodeException { RouteRequest request = new RouteRequest(start, end); request.setProfile(profile); @@ -99,25 +110,37 @@ public GeoJSONRouteResponse getSimpleGeoJsonRoute(@ApiParam(value = "Specifies t } @PostMapping(value = "/{profile}") - @ApiOperation(notes = "Returns a route between two or more locations for a selected profile and its settings as JSON", value = "Directions Service (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses( - @ApiResponse(code = 200, - message = "Standard response for successfully processed requests. Returns JSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).", - response = JSONRouteResponse.class) - ) - public JSONRouteResponse getDefault(@ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { + @RouterOperation(operation = @Operation(description = "Returns a route between two or more locations for a selected profile and its settings as JSON", summary = "Directions Service (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns JSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).", + content = {@Content( + mediaType = "application/json", + array = @ArraySchema(schema = @Schema(implementation = JSONRouteResponse.class)) + ) + }) + public JSONRouteResponse getDefault(@Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { return getJsonRoute(profile, request); } @PostMapping(value = "/{profile}/json", produces = {"application/json;charset=UTF-8"}) - @ApiOperation(notes = "Returns a route between two or more locations for a selected profile and its settings as JSON", value = "Directions Service JSON (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "JSON Response", response = JSONRouteResponse.class) - }) + @RouterOperation(operation = @Operation(description = "Returns a route between two or more locations for a selected profile and its settings as JSON", summary = "Directions Service JSON (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/json") + @ApiResponse(responseCode = "200", + description = "JSON Response", + content = {@Content( + mediaType = "application/json", + array = @ArraySchema(schema = @Schema(implementation = JSONRouteResponse.class)) + ) + }) public JSONRouteResponse getJsonRoute( - @ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { + @Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { request.setProfile(profile); request.setResponseType(APIEnums.RouteResponseType.JSON); @@ -127,16 +150,21 @@ public JSONRouteResponse getJsonRoute( } @PostMapping(value = "/{profile}/gpx", produces = "application/gpx+xml;charset=UTF-8") - @ApiOperation(notes = "Returns a route between two or more locations for a selected profile and its settings as GPX. The schema can be found [here](https://raw.githubusercontent.com/GIScience/openrouteservice-schema/master/gpx/v1/ors-gpx.xsd)", - value = "Directions Service GPX (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/gpx+xml") - @ApiResponses(value = { - @ApiResponse(code = 200, - message = "Standard response for successfully processed requests. Returns GPX.", - response = GPXRouteResponse.class) - }) + @RouterOperation(operation = @Operation(description = "Returns a route between two or more locations for a selected profile and its settings as GPX. The schema can be found [here](https://raw.githubusercontent.com/GIScience/openrouteservice-schema/master/gpx/v1/ors-gpx.xsd)", + summary = "Directions Service GPX (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/gpx+xml") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns GPX.", + content = {@Content( + mediaType = "application/gpx+xml", + array = @ArraySchema(schema = @Schema(implementation = GPXRouteResponse.class)) + ) + }) public GPXRouteResponse getGPXRoute( - @ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { + @Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { request.setProfile(profile); request.setResponseType(APIEnums.RouteResponseType.GPX); @@ -147,15 +175,21 @@ public GPXRouteResponse getGPXRoute( } @PostMapping(value = "/{profile}/geojson", produces = "application/geo+json;charset=UTF-8") - @ApiOperation(notes = "Returns a route between two or more locations for a selected profile and its settings as GeoJSON", value = "Directions Service GeoJSON (POST)", httpMethod = "POST", consumes = "application/json", produces = "application/geo+json") - @ApiResponses(value = { - @ApiResponse(code = 200, - message = "Standard response for successfully processed requests. Returns GeoJSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).", - response = GeoJSONRouteResponse.class) - }) + @RouterOperation(operation = @Operation(description = "Returns a route between two or more locations for a selected profile and its settings as GeoJSON", + summary = "Directions Service GeoJSON (POST)"), + method = RequestMethod.POST, + consumes = "application/json", + produces = "application/geo+json") + @ApiResponse(responseCode = "200", + description = "Standard response for successfully processed requests. Returns GeoJSON. The decoded values of the extra information can be found [here](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html).", + content = {@Content( + mediaType = "application/geo+json", + array = @ArraySchema(schema = @Schema(implementation = GeoJSONRouteResponse.class)) + ) + }) public GeoJSONRouteResponse getGeoJsonRoute( - @ApiParam(value = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, - @ApiParam(value = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { + @Parameter(description = "Specifies the route profile.", required = true, example = "driving-car") @PathVariable APIEnums.Profile profile, + @Parameter(description = "The request payload", required = true) @RequestBody RouteRequest request) throws StatusCodeException { request.setProfile(profile); request.setResponseType(APIEnums.RouteResponseType.GEOJSON); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/centrality/CentralityRequest.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/centrality/CentralityRequest.java index 4dcfef85a9..85e6d6658f 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/centrality/CentralityRequest.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/centrality/CentralityRequest.java @@ -5,8 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.primitives.Doubles; import com.graphhopper.util.shapes.BBox; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.common.APIRequest; import org.heigit.ors.centrality.CentralityErrorCodes; @@ -18,7 +17,7 @@ import java.util.List; -@ApiModel(value = "Centrality Service", description = "The JSON body request sent to the centrality service which defines options and parameters regarding the centrality measure to calculate.") +@Schema(name = "Centrality Service", description = "The JSON body request sent to the centrality service which defines options and parameters regarding the centrality measure to calculate.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class CentralityRequest extends APIRequest { public static final String PARAM_BBOX = "bbox"; @@ -26,23 +25,23 @@ public class CentralityRequest extends APIRequest { public static final String PARAM_MODE = "mode"; public static final String PARAM_FORMAT = "format"; - @ApiModelProperty(name = PARAM_BBOX, value = "The bounding box to use for the request as an array of `longitude/latitude` pairs in WGS 84 (EPSG:4326)", + @Schema(name= PARAM_BBOX, description = "The bounding box to use for the request as an array of `longitude/latitude` pairs in WGS 84 (EPSG:4326)", example = "[8.681495,49.41461,8.686507,49.41943]", - required = true) + accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_BBOX) private List> bbox; //apparently, this has to be a non-primitive type… - @ApiModelProperty(name = PARAM_EXCLUDENODES, value = "List of node Ids to exclude when calculating centrality", + @Schema(name= PARAM_EXCLUDENODES, description = "List of node Ids to exclude when calculating centrality", example = "[1661, 1662, 1663]") @JsonProperty(PARAM_EXCLUDENODES) private List excludeNodes; private boolean hasExcludeNodes = false; - @ApiModelProperty(name = PARAM_FORMAT, hidden = true) + @Schema(name= PARAM_FORMAT, accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_FORMAT) private APIEnums.CentralityResponseType responseType = APIEnums.CentralityResponseType.JSON; - @ApiModelProperty(name = PARAM_MODE, value = "Specifies the centrality calculation mode. Currently, node-based and edge-based centrality calculation is supported.", example = "nodes") + @Schema(name= PARAM_MODE, description = "Specifies the centrality calculation mode. Currently, node-based and edge-based centrality calculation is supported.", example = "nodes") @JsonProperty(PARAM_MODE) private CentralityRequestEnums.Mode mode = CentralityRequestEnums.Mode.NODES; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIEnums.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIEnums.java index 0bd34d8c4c..6aa84fa278 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIEnums.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIEnums.java @@ -18,13 +18,13 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.exceptions.ParameterValueException; -import io.swagger.annotations.ApiModel; import static org.heigit.ors.api.errors.GenericErrorCodes.INVALID_PARAMETER_VALUE; public class APIEnums { - @ApiModel(value = "Specify which type of border crossing to avoid") + @Schema(name = "Avoid borders", description = "Specify which type of border crossing to avoid") public enum AvoidBorders { ALL("all"), CONTROLLED("controlled"), @@ -53,7 +53,7 @@ public String toString() { } } - @ApiModel(value = "Specify which extra info items to include in the response") + @Schema(name = "Extra information", description = "Specify which extra info items to include in the response") public enum ExtraInfo { STEEPNESS("steepness"), SUITABILITY("suitability"), @@ -93,7 +93,7 @@ public String toString() { } - @ApiModel + @Schema(name = "Route response type", description = "Format of the route response.") public enum RouteResponseType { GPX("gpx"), JSON("json"), @@ -121,7 +121,7 @@ public String toString() { } } - @ApiModel + @Schema(name = "Matrix response type", description = "Format of the Matrix response.") public enum MatrixResponseType { JSON("json"); @@ -147,7 +147,7 @@ public String toString() { } } - @ApiModel + @Schema(name = "Centrality response type", description = "Format of the Centrality response.") public enum CentralityResponseType { JSON("json"); @@ -173,7 +173,7 @@ public String toString() { } } - @ApiModel + @Schema(name = "Vehicle type", description = "Definition of the vehicle type.") public enum VehicleType { HGV("hgv"), BUS("bus"), @@ -205,7 +205,7 @@ public String toString() { } } - @ApiModel + @Schema(name = "Avoid features", description = "Definition of the features to be avoided.") public enum AvoidFeatures { HIGHWAYS("highways"), TOLLWAYS("tollways"), @@ -235,7 +235,7 @@ public String toString() { } } - @ApiModel(value = "Preference", description = "Specifies the route preference") + @Schema(name = "Preference", description = "Specifies the route preference") public enum RoutePreference { FASTEST("fastest"), SHORTEST("shortest"), diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIRequest.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIRequest.java index d33d1afdc9..a9065cc5de 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIRequest.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/APIRequest.java @@ -2,10 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.MultiPolygon; -import org.locationtech.jts.geom.Polygon; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.errors.GenericErrorCodes; import org.heigit.ors.api.requests.routing.RequestProfileParamsRestrictions; import org.heigit.ors.api.requests.routing.RequestProfileParamsWeightings; @@ -28,21 +25,26 @@ import org.heigit.ors.util.GeomUtility; import org.heigit.ors.util.StringUtility; import org.json.simple.JSONObject; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.MultiPolygon; +import org.locationtech.jts.geom.Polygon; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; public class APIRequest { public static final String PARAM_ID = "id"; public static final String PARAM_PROFILE = "profile"; - @ApiModelProperty(name = PARAM_ID, value = "Arbitrary identification string of the request reflected in the meta information.", + @Schema(name = PARAM_ID, description = "Arbitrary identification string of the request reflected in the meta information.", example = "centrality_request") @JsonProperty(PARAM_ID) protected String id; @JsonIgnore private boolean hasId = false; - @ApiModelProperty(name = PARAM_PROFILE, hidden = true) + @Schema(name = PARAM_PROFILE, accessMode = Schema.AccessMode.READ_ONLY) protected APIEnums.Profile profile; public boolean hasId() { diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/CoordinateListWrapper.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/CoordinateListWrapper.java index e25b1a94df..990fcafcb9 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/CoordinateListWrapper.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/CoordinateListWrapper.java @@ -17,16 +17,15 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.locationtech.jts.geom.Coordinate; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.converters.CoordinateListDeserializer; import org.heigit.ors.exceptions.ParameterValueException; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import org.locationtech.jts.geom.Coordinate; import java.util.ArrayList; import java.util.List; -@ApiModel(value = "Coordinates", description = "An array of waypoints in the longitude/latitude pairs.") +@Schema(name = "Coordinates", description = "An array of waypoints in the longitude/latitude pairs.") @JsonDeserialize(using = CoordinateListDeserializer.class) public class CoordinateListWrapper { @JsonIgnore @@ -91,7 +90,7 @@ public List getVia() { return via; } - @ApiModelProperty + @Schema(name = "Coordinate array", description = "Get all coordinates as an array.") public Coordinate[] getCoordinates() { List coordinates = new ArrayList<>(); coordinates.add(start); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/RequestOptions.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/RequestOptions.java index e9e51e66c3..24abd8e3cf 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/RequestOptions.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/common/RequestOptions.java @@ -18,13 +18,12 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.matrix.MatrixRequest; import org.heigit.ors.api.requests.routing.RequestProfileParams; import org.json.simple.JSONObject; -@ApiModel(value = "Matrix Options", description = "Advanced options for matrix", subTypes = {MatrixRequest.class}) +@Schema(name = "Matrix Options", description = "Advanced options for matrix", subTypes = {MatrixRequest.class}) @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class RequestOptions { public static final String PARAM_AVOID_FEATURES = "avoid_features"; @@ -34,7 +33,7 @@ public class RequestOptions { public static final String PARAM_PROFILE_PARAMS = "profile_params"; public static final String PARAM_AVOID_POLYGONS = "avoid_polygons"; - @ApiModelProperty(name = PARAM_AVOID_FEATURES, value = "List of features to avoid. " + + @Schema(name = PARAM_AVOID_FEATURES, description = "List of features to avoid. " + "CUSTOM_KEYS:{'itemRestrictions':{'ref':'profile', 'itemsWhen':{'driving-*':['highways','tollways','ferries'],'cycling-*':['ferries','steps','fords'],'foot-*':['ferries','fords','steps'],'wheelchair':['ferries','steps']}}}", example = "[\"highways\"]") @JsonProperty(PARAM_AVOID_FEATURES) @@ -42,7 +41,7 @@ public class RequestOptions { @JsonIgnore private boolean hasAvoidFeatures = false; - @ApiModelProperty(name = PARAM_AVOID_BORDERS, value = "`all` for no border crossing. `controlled` to cross open borders but avoid controlled ones. Only for `driving-*` profiles. " + + @Schema(name = PARAM_AVOID_BORDERS, description = "`all` for no border crossing. `controlled` to cross open borders but avoid controlled ones. Only for `driving-*` profiles. " + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-*']}}", example = "controlled") @JsonProperty(PARAM_AVOID_BORDERS) @@ -50,7 +49,7 @@ public class RequestOptions { @JsonIgnore private boolean hasAvoidBorders = false; - @ApiModelProperty(name = PARAM_AVOID_COUNTRIES, value = "List of countries to exclude from matrix with `driving-*` profiles. Can be used together with `'avoid_borders': 'controlled'`. " + + @Schema(name = PARAM_AVOID_COUNTRIES, description = "List of countries to exclude from matrix with `driving-*` profiles. Can be used together with `'avoid_borders': 'controlled'`. " + "`[ 11, 193 ]` would exclude Austria and Switzerland. List of countries and application examples can be found [here](https://GIScience.github.io/openrouteservice/documentation/routing-options/Country-List.html). " + "Also, ISO standard country codes cna be used in place of the numerical ids, for example, DE or DEU for Germany. " + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-*']}}", @@ -60,21 +59,21 @@ public class RequestOptions { @JsonIgnore private boolean hasAvoidCountries = false; - @ApiModelProperty(name = PARAM_VEHICLE_TYPE, value = "(for profile=driving-hgv only): hgv,bus,agricultural,delivery,forestry and goods. It is needed for vehicle restrictions to work. " + + @Schema(name = PARAM_VEHICLE_TYPE, description = "(for profile=driving-hgv only): hgv,bus,agricultural,delivery,forestry and goods. It is needed for vehicle restrictions to work. " + "CUSTOM_KEYS:{'apiDefault':'hgv','validWhen':{'ref':'profile','value':['driving-hgv']}}") @JsonProperty(value = PARAM_VEHICLE_TYPE) private APIEnums.VehicleType vehicleType; @JsonIgnore private boolean hasVehicleType = false; - @ApiModelProperty(name = PARAM_PROFILE_PARAMS, value = " Specifies additional matrix parameters." + + @Schema(name = PARAM_PROFILE_PARAMS, description = " Specifies additional matrix parameters." + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','valueNot':['driving-car']}}") @JsonProperty(PARAM_PROFILE_PARAMS) private RequestProfileParams profileParams; @JsonIgnore private boolean hasProfileParams = false; - @ApiModelProperty(name = PARAM_AVOID_POLYGONS, value = "Comprises areas to be avoided for the route. Formatted in GeoJSON as either a Polygon or Multipolygon object.") + @Schema(name = PARAM_AVOID_POLYGONS, description = "Comprises areas to be avoided for the route. Formatted in GeoJSON as either a Polygon or Multipolygon object.") @JsonProperty(PARAM_AVOID_POLYGONS) private JSONObject avoidPolygonFeatures; @JsonIgnore diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/export/ExportRequest.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/export/ExportRequest.java index 39e20b9f71..aeef371f9c 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/export/ExportRequest.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/export/ExportRequest.java @@ -6,8 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.primitives.Doubles; import com.graphhopper.util.shapes.BBox; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.common.APIRequest; import org.heigit.ors.common.StatusCode; @@ -19,7 +18,7 @@ import java.util.List; -@ApiModel(value = "Centrality Service", description = "The JSON body request sent to the centrality service which defines options and parameters regarding the centrality measure to calculate.") +@Schema(name = "Centrality Service", description = "The JSON body request sent to the centrality service which defines options and parameters regarding the centrality measure to calculate.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class ExportRequest extends APIRequest { public static final String PARAM_ID = "id"; @@ -29,27 +28,27 @@ public class ExportRequest extends APIRequest { public static final String PARAM_DEBUG = "debug"; - @ApiModelProperty(name = PARAM_ID, value = "Arbitrary identification string of the request reflected in the meta information.", + @Schema(name= PARAM_ID, description = "Arbitrary identification string of the request reflected in the meta information.", example = "centrality_request") @JsonProperty(PARAM_ID) private String id; @JsonIgnore private boolean hasId = false; - @ApiModelProperty(name = PARAM_PROFILE, hidden = true) + @Schema(name= PARAM_PROFILE, accessMode = Schema.AccessMode.READ_ONLY) private APIEnums.Profile profile; - @ApiModelProperty(name = PARAM_BBOX, value = "The bounding box to use for the request as an array of `longitude/latitude` pairs", + @Schema(name= PARAM_BBOX, description = "The bounding box to use for the request as an array of `longitude/latitude` pairs", example = "[8.681495,49.41461,8.686507,49.41943]", required = true) @JsonProperty(PARAM_BBOX) private List> bbox; //apparently, this has to be a non-primitive type… - @ApiModelProperty(name = PARAM_FORMAT, hidden = true) + @Schema(name= PARAM_FORMAT, accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_FORMAT) private APIEnums.CentralityResponseType responseType = APIEnums.CentralityResponseType.JSON; - @ApiModelProperty(name = PARAM_DEBUG, hidden = true) + @Schema(name= PARAM_DEBUG, accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_DEBUG) private boolean debug; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/isochrones/IsochronesRequest.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/isochrones/IsochronesRequest.java index 09fec42f64..66838de789 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/isochrones/IsochronesRequest.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/isochrones/IsochronesRequest.java @@ -19,9 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.common.APIRequest; import org.heigit.ors.api.requests.routing.RouteRequestOptions; @@ -39,6 +37,7 @@ import org.heigit.ors.routing.RoutingProfileManager; import org.heigit.ors.routing.RoutingProfileType; import org.heigit.ors.util.DistanceUnitUtil; +import org.locationtech.jts.geom.Coordinate; import java.time.LocalDateTime; import java.util.Arrays; @@ -48,7 +47,7 @@ import static org.heigit.ors.api.requests.isochrones.IsochronesRequestEnums.CalculationMethod.FASTISOCHRONE; -@ApiModel(value = "IsochronesRequest", description = "The JSON body request sent to the isochrones service which defines options and parameters regarding the isochrones to generate.") +@Schema(name = "IsochronesRequest", description = "The JSON body request sent to the isochrones service which defines options and parameters regarding the isochrones to generate.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class IsochronesRequest extends APIRequest { public static final String PARAM_LOCATIONS = "locations"; @@ -65,40 +64,40 @@ public class IsochronesRequest extends APIRequest { public static final String PARAM_TIME = "time"; - @ApiModelProperty(name = PARAM_LOCATIONS, value = "The locations to use for the route as an array of `longitude/latitude` pairs in WGS 84 (EPSG:4326)", + @Schema(name= PARAM_LOCATIONS, description = "The locations to use for the route as an array of `longitude/latitude` pairs in WGS 84 (EPSG:4326)", example = "[[8.681495,49.41461],[8.686507,49.41943]]", - required = true) + accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_LOCATIONS) private Double[][] locations = new Double[][]{}; @JsonIgnore private boolean hasLocations = false; - @ApiModelProperty(name = PARAM_LOCATION_TYPE, value = "`start` treats the location(s) as starting point, `destination` as goal. CUSTOM_KEYS:{'apiDefault':'start'}", + @Schema(name= PARAM_LOCATION_TYPE, description = "`start` treats the location(s) as starting point, `destination` as goal. CUSTOM_KEYS:{'apiDefault':'start'}", example = "start") @JsonProperty(value = PARAM_LOCATION_TYPE) private IsochronesRequestEnums.LocationType locationType; @JsonIgnore private boolean hasLocationType = false; - @ApiModelProperty(name = PARAM_RANGE, value = "Maximum range value of the analysis in **seconds** for time and **metres** for distance." + + @Schema(name= PARAM_RANGE, description = "Maximum range value of the analysis in **seconds** for time and **metres** for distance." + "Alternatively a comma separated list of specific range values. Ranges will be the same for all locations.", example = "[ 300, 200 ]", - required = true) + accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_RANGE) private List range; @JsonIgnore private boolean hasRange = false; - @ApiModelProperty(name = PARAM_RANGE_TYPE, - value = "Specifies the isochrones reachability type. CUSTOM_KEYS:{'apiDefault':'time'}", example = "time") + @Schema(name= PARAM_RANGE_TYPE, + description = "Specifies the isochrones reachability type. CUSTOM_KEYS:{'apiDefault':'time'}", example = "time") @JsonProperty(value = PARAM_RANGE_TYPE, defaultValue = "time") private IsochronesRequestEnums.RangeType rangeType; @JsonIgnore private boolean hasRangeType = false; // unit only valid for range_type distance, will be ignored for range_time time - @ApiModelProperty(name = PARAM_RANGE_UNITS, - value = "Specifies the distance units only if `range_type` is set to distance.\n" + + @Schema(name= PARAM_RANGE_UNITS, + description = "Specifies the distance units only if `range_type` is set to distance.\n" + "Default: m. " + "CUSTOM_KEYS:{'apiDefault':'m','validWhen':{'ref':'range_type','value':'distance'}}", example = "m") @@ -107,19 +106,19 @@ public class IsochronesRequest extends APIRequest { @JsonIgnore private boolean hasRangeUnits = false; - @ApiModelProperty(name = PARAM_OPTIONS, - value = "Additional options for the isochrones request", + @Schema(name= PARAM_OPTIONS, + description = "Additional options for the isochrones request", example = "{\"avoid_borders\":\"all\"}") @JsonProperty(PARAM_OPTIONS) private RouteRequestOptions isochronesOptions; @JsonIgnore private boolean hasOptions = false; - @ApiModelProperty(hidden = true) + @Schema(accessMode = Schema.AccessMode.READ_ONLY) private APIEnums.RouteResponseType responseType = APIEnums.RouteResponseType.GEOJSON; - @ApiModelProperty(name = PARAM_AREA_UNITS, - value = "Specifies the area unit.\n" + + @Schema(name= PARAM_AREA_UNITS, + description = "Specifies the area unit.\n" + "Default: m. " + "CUSTOM_KEYS:{'apiDefault':'m','validWhen':{'ref':'attributes','value':'area'}}") @JsonProperty(value = PARAM_AREA_UNITS) @@ -127,22 +126,22 @@ public class IsochronesRequest extends APIRequest { @JsonIgnore private boolean hasAreaUnits = false; - @ApiModelProperty(name = PARAM_INTERSECTIONS, - value = "Specifies whether to return intersecting polygons. " + + @Schema(name= PARAM_INTERSECTIONS, + description = "Specifies whether to return intersecting polygons. " + "CUSTOM_KEYS:{'apiDefault':false}") @JsonProperty(value = PARAM_INTERSECTIONS) private boolean intersections; @JsonIgnore private boolean hasIntersections = false; - @ApiModelProperty(name = PARAM_ATTRIBUTES, value = "List of isochrones attributes", + @Schema(name= PARAM_ATTRIBUTES, description = "List of isochrones attributes", example = "[\"area\"]") @JsonProperty(PARAM_ATTRIBUTES) private IsochronesRequestEnums.Attributes[] attributes; @JsonIgnore private boolean hasAttributes = false; - @ApiModelProperty(name = PARAM_INTERVAL, value = "Interval of isochrones or equidistants. This is only used if a single range value is given. " + + @Schema(name= PARAM_INTERVAL, description = "Interval of isochrones or equidistants. This is only used if a single range value is given. " + "Value in **seconds** for time and **meters** for distance.", example = "30" ) @@ -151,8 +150,8 @@ public class IsochronesRequest extends APIRequest { @JsonIgnore private boolean hasInterval = false; - @ApiModelProperty(name = PARAM_SMOOTHING, - value = "Applies a level of generalisation to the isochrone polygons generated as a `smoothing_factor` between `0` and `100.0`.\n" + + @Schema(name= PARAM_SMOOTHING, + description = "Applies a level of generalisation to the isochrone polygons generated as a `smoothing_factor` between `0` and `100.0`.\n" + "Generalisation is produced by determining a maximum length of a connecting line between two points found on the outside of a containing polygon.\n" + "If the distance is larger than a threshold value, the line between the two points is removed and a smaller connecting line between other points is used.\n" + "Note that the minimum length of this connecting line is ~1333m, and so when the `smoothing_factor` results in a distance smaller than this, the minimum value is used.\n" + @@ -165,8 +164,8 @@ public class IsochronesRequest extends APIRequest { @JsonIgnore private boolean hasSmoothing = false; - @ApiModelProperty(name = PARAM_TIME, value = "Departure date and time provided in local time zone", - example = "2020-01-31T12:45:00", hidden = true) + @Schema(name= PARAM_TIME, description = "Departure date and time provided in local time zone", + example = "2020-01-31T12:45:00", accessMode = Schema.AccessMode.READ_ONLY) @JsonProperty(PARAM_TIME) private LocalDateTime time; @JsonIgnore diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequest.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequest.java index 68592a9626..3d44412da6 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequest.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequest.java @@ -19,12 +19,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.common.APIRequest; import org.heigit.ors.api.requests.routing.RouteRequest; +import org.heigit.ors.config.MatrixServiceSettings; import org.heigit.ors.exceptions.ParameterValueException; import org.heigit.ors.exceptions.ServerLimitExceededException; import org.heigit.ors.exceptions.StatusCodeException; @@ -35,14 +34,14 @@ import org.heigit.ors.routing.RoutingErrorCodes; import org.heigit.ors.routing.RoutingProfileManager; import org.heigit.ors.routing.RoutingProfileType; -import org.heigit.ors.config.MatrixServiceSettings; +import org.locationtech.jts.geom.Coordinate; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -@ApiModel(value = "MatrixRequest", description = "The JSON body request sent to the matrix service which defines options and parameters regarding the matrix to generate.") +@Schema(name = "MatrixRequest", description = "The JSON body request sent to the matrix service which defines options and parameters regarding the matrix to generate.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class MatrixRequest extends APIRequest { public static final String PARAM_LOCATIONS = "locations"; @@ -54,35 +53,37 @@ public class MatrixRequest extends APIRequest { public static final String PARAM_OPTIMIZED = "optimized"; public static final String PARAM_OPTIONS = "options"; - @ApiModelProperty(name = PARAM_LOCATIONS, value = "List of comma separated lists of `longitude,latitude` coordinates in WGS 84 (EPSG:4326)", + @Schema(name = PARAM_LOCATIONS, description = "List of comma separated lists of `longitude,latitude` coordinates in WGS 84 (EPSG:4326)", example = "[[9.70093, 48.477473], [9.207916, 49.153868], [37.573242, 55.801281], [115.663757, 38.106467]]", required = true) @JsonProperty(PARAM_LOCATIONS) private List> locations; - @ApiModelProperty(name = PARAM_SOURCES, value = "A list of indices that refers to the list of locations (starting with `0`). `{index_1},{index_2}[,{index_N} ...]` or `all` (default). example `[0,3]` for the first and fourth locations " + + @Schema(name = PARAM_SOURCES, description = "A list of indices that refers to the list of locations (starting with `0`). `{index_1},{index_2}[,{index_N} ...]` or `all` (default). example `[0,3]` for the first and fourth locations " + "CUSTOM_KEYS:{'apiDefault':['all']}") @JsonProperty(value = PARAM_SOURCES) private String[] sources; @JsonIgnore private boolean hasSources = false; - @ApiModelProperty(name = PARAM_DESTINATIONS, value = "A list of indices that refers to the list of locations (starting with `0`). `{index_1},{index_2}[,{index_N} ...]` or `all` (default). `[0,3]` for the first and fourth locations " + + @Schema(name = PARAM_DESTINATIONS, description = "A list of indices that refers to the list of locations (starting with `0`). `{index_1},{index_2}[,{index_N} ...]` or `all` (default). `[0,3]` for the first and fourth locations " + "CUSTOM_KEYS:{'apiDefault':['all']}") @JsonProperty(value = PARAM_DESTINATIONS) private String[] destinations; @JsonIgnore private boolean hasDestinations = false; - @ApiModelProperty(name = PARAM_METRICS, value = "Specifies a list of returned metrics.\n" + - "* `distance` - Returns distance matrix for specified points in defined `units`.\n* `duration` - Returns duration matrix for specified points in **seconds**. " + - "CUSTOM_KEYS:{'apiDefault':'duration'}") + @Schema(name = PARAM_METRICS, description = """ + Specifies a list of returned metrics. + "* `distance` - Returns distance matrix for specified points in defined `units`. + * `duration` - Returns duration matrix for specified points in **seconds**. + "CUSTOM_KEYS:{'apiDefault':'duration'}""") @JsonProperty(value = PARAM_METRICS) private MatrixRequestEnums.Metrics[] metrics; @JsonIgnore private boolean hasMetrics = false; - @ApiModelProperty(name = PARAM_RESOLVE_LOCATIONS, value = "Specifies whether given locations are resolved or not. If the parameter value set to `true`, every element in " + + @Schema(name = PARAM_RESOLVE_LOCATIONS, description = "Specifies whether given locations are resolved or not. If the parameter value set to `true`, every element in " + "`destinations` and `sources` will contain a `name` element that identifies the name of the closest street. Default is `false`. " + "CUSTOM_KEYS:{'apiDefault':false}") @JsonProperty(value = PARAM_RESOLVE_LOCATIONS) @@ -90,27 +91,27 @@ public class MatrixRequest extends APIRequest { @JsonIgnore private boolean hasResolveLocations = false; - @ApiModelProperty(name = PARAM_UNITS, value = "Specifies the distance unit.\n" + + @Schema(name = PARAM_UNITS, description = "Specifies the distance unit.\n" + "Default: m. CUSTOM_KEYS:{'apiDefault':'m','validWhen':{'ref':'metrics','value':'distance'}`}") @JsonProperty(value = PARAM_UNITS) private APIEnums.Units units; @JsonIgnore private boolean hasUnits = false; - @ApiModelProperty(name = PARAM_OPTIMIZED, value = "Specifies whether flexible mode is used or not.", hidden = true) + @Schema(name = PARAM_OPTIMIZED, description = "Specifies whether flexible mode is used or not.", hidden = true) @JsonProperty(value = PARAM_OPTIMIZED) private Boolean optimized; @JsonIgnore private boolean hasOptimized = false; - @ApiModelProperty(name = PARAM_OPTIONS, - value = "For advanced options formatted as json object. For structure refer to the [these examples](https://GIScience.github.io/openrouteservice/documentation/routing-options/Examples.html).", + @Schema(name = PARAM_OPTIONS, + description = "For advanced options formatted as json object. For structure refer to the [these examples](https://GIScience.github.io/openrouteservice/documentation/routing-options/Examples.html).", example = "{\"avoid_borders\":\"controlled\"}", hidden = true) @JsonProperty(PARAM_OPTIONS) private MatrixRequestOptions matrixOptions; - @ApiModelProperty(hidden = true) + @Schema(hidden = true) private APIEnums.MatrixResponseType responseType; @JsonCreator diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequestOptions.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequestOptions.java index 202e89545c..ba540e6427 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequestOptions.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/matrix/MatrixRequestOptions.java @@ -18,16 +18,15 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.RequestOptions; -@ApiModel(value = "Matrix Options", description = "Advanced options for matrix", subTypes = {MatrixRequest.class}) +@Schema(name = "Matrix Options", description = "Advanced options for matrix", subTypes = {MatrixRequest.class}) @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class MatrixRequestOptions extends RequestOptions { public static final String PARAM_DYNAMIC_SPEEDS = "dynamic_speeds"; - @ApiModelProperty(name = PARAM_DYNAMIC_SPEEDS, value = "Option to use dynamic speed updates on some pre-defined speeds.", + @Schema(name = PARAM_DYNAMIC_SPEEDS, description = "Option to use dynamic speed updates on some pre-defined speeds.", example = "{true}") @JsonProperty(PARAM_DYNAMIC_SPEEDS) private boolean dynamicSpeeds; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParams.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParams.java index 485bb566a3..e9de295f9f 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParams.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParams.java @@ -18,10 +18,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; -@ApiModel(value = "Profile Parameters", parent = RouteRequestOptions.class, description = "Specifies additional routing parameters. For all profiles except `driving-car`.") +@Schema(name = "Profile Parameters", description = "Specifies additional routing parameters. For all profiles except `driving-car`.", subTypes = {RequestProfileParamsRestrictions.class, RequestProfileParamsWeightings.class}) @JsonInclude(JsonInclude.Include.NON_EMPTY) public class RequestProfileParams { public static final String PARAM_WEIGHTINGS = "weightings"; @@ -39,7 +38,7 @@ public class RequestProfileParams { @JsonIgnore private boolean hasRestrictions = false; - @ApiModelProperty(name = PARAM_SURFACE_QUALITY_KNOWN, value = "Specifies whether to enforce that only ways with known information on surface quality be taken into account - default false" + + @Schema(name= PARAM_SURFACE_QUALITY_KNOWN, description = "Specifies whether to enforce that only ways with known information on surface quality be taken into account - default false" + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['wheelchair']}}", example = "true") @JsonProperty(PARAM_SURFACE_QUALITY_KNOWN) @@ -47,7 +46,7 @@ public class RequestProfileParams { @JsonIgnore private boolean hasSurfaceQualityKnown = false; - @ApiModelProperty(name = PARAM_ALLOW_UNSUITABLE, value = "Specifies if ways that might not be suitable (e.g. unknown pedestrian usage) should be included in finding routes - default false" + + @Schema(name= PARAM_ALLOW_UNSUITABLE, description = "Specifies if ways that might not be suitable (e.g. unknown pedestrian usage) should be included in finding routes - default false" + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['wheelchair']}}", example = "true") @JsonProperty(PARAM_ALLOW_UNSUITABLE) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsRestrictions.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsRestrictions.java index 5084648c78..a44bcca997 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsRestrictions.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsRestrictions.java @@ -18,14 +18,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import java.util.ArrayList; import java.util.List; -@ApiModel(value = "Restrictions", parent = RequestProfileParams.class, description = "Describe restrictions to be applied to edges on the routing. any edges that do not match these restrictions are not traversed.") +@Schema(name = "Restrictions", description = "Describe restrictions to be applied to edges on the routing. any edges that do not match these restrictions are not traversed.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class RequestProfileParamsRestrictions { public static final String PARAM_LENGTH = "length"; @@ -41,46 +40,46 @@ public class RequestProfileParamsRestrictions { public static final String PARAM_MAX_INCLINE = "maximum_incline"; public static final String PARAM_MIN_WIDTH = "minimum_width"; - @ApiModelProperty(name = PARAM_LENGTH, value = "Length restriction in metres. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "8.4") + @Schema(name= PARAM_LENGTH, description = "Length restriction in metres. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "8.4") @JsonProperty(PARAM_LENGTH) private Float length; private boolean hasLength = false; - @ApiModelProperty(name = PARAM_WIDTH, value = "Width restriction in metres. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "5.6") + @Schema(name= PARAM_WIDTH, description = "Width restriction in metres. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "5.6") @JsonProperty(PARAM_WIDTH) private Float width; @JsonIgnore private boolean hasWidth = false; - @ApiModelProperty(name = PARAM_HEIGHT, value = "Height restriction in metres. " + + @Schema(name= PARAM_HEIGHT, description = "Height restriction in metres. " + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "4.2") @JsonProperty(PARAM_HEIGHT) private Float height; @JsonIgnore private boolean hasHeight = false; - @ApiModelProperty(name = PARAM_AXLE_LOAD, value = "Axleload restriction in tons. " + + @Schema(name= PARAM_AXLE_LOAD, description = "Axleload restriction in tons. " + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "50") @JsonProperty(PARAM_AXLE_LOAD) private Float axleLoad; @JsonIgnore private boolean hasAxleLoad = false; - @ApiModelProperty(name = PARAM_WEIGHT, value = "Weight restriction in tons. " + + @Schema(name= PARAM_WEIGHT, description = "Weight restriction in tons. " + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-hgv']}}", example = "40") @JsonProperty(PARAM_WEIGHT) private Float weight; @JsonIgnore private boolean hasWeight = false; - @ApiModelProperty(name = PARAM_HAZMAT, value = "Specifies whether to use appropriate routing for delivering hazardous goods and avoiding water protected areas. Default is `false`. " + + @Schema(name= PARAM_HAZMAT, description = "Specifies whether to use appropriate routing for delivering hazardous goods and avoiding water protected areas. Default is `false`. " + "CUSTOM_KEYS:{'apiDefault':false,'validWhen':{'ref':'profile','value':['driving-hgv']}}") @JsonProperty(value = PARAM_HAZMAT) private boolean hazardousMaterial; @JsonIgnore private boolean hasHazardousMaterial = false; - @ApiModelProperty(name = PARAM_SURFACE_TYPE, value = "Specifies the minimum surface type. Default is `sett`. " + + @Schema(name= PARAM_SURFACE_TYPE, description = "Specifies the minimum surface type. Default is `sett`. " + "CUSTOM_KEYS:{'apiDefault':'sett','validWhen':{'ref':'profile','value':['wheelchair']}}", example = "asphalt") @JsonProperty(PARAM_SURFACE_TYPE) @@ -88,7 +87,7 @@ public class RequestProfileParamsRestrictions { @JsonIgnore private boolean hasSurfaceType = false; - @ApiModelProperty(name = PARAM_TRACK_TYPE, value = "Specifies the minimum grade of the route. Default is `grade1`. " + + @Schema(name= PARAM_TRACK_TYPE, description = "Specifies the minimum grade of the route. Default is `grade1`. " + "CUSTOM_KEYS:{'apiDefault':'grade1','validWhen':{'ref':'profile','value':['wheelchair']}}", example = "grade2") @JsonProperty(PARAM_TRACK_TYPE) @@ -96,7 +95,7 @@ public class RequestProfileParamsRestrictions { @JsonIgnore private boolean hasTrackType = false; - @ApiModelProperty(name = PARAM_SMOOTHNESS_TYPE, value = "Specifies the minimum smoothness of the route. Default is `good`." + + @Schema(name= PARAM_SMOOTHNESS_TYPE, description = "Specifies the minimum smoothness of the route. Default is `good`." + "CUSTOM_KEYS:{'apiDefault':'good','validWhen':{'ref':'profile','value':['wheelchair']}}", example = "best") @JsonProperty(value = PARAM_SMOOTHNESS_TYPE) @@ -104,7 +103,7 @@ public class RequestProfileParamsRestrictions { @JsonIgnore private boolean hasSmoothnessType = false; - @ApiModelProperty(name = PARAM_MAXIMUM_SLOPED_KERB, value = "Specifies the maximum height of the sloped curb in metres. Values are `0.03`, `0.06` (default), `0.1`." + + @Schema(name= PARAM_MAXIMUM_SLOPED_KERB, description = "Specifies the maximum height of the sloped curb in metres. Values are `0.03`, `0.06` (default), `0.1`." + "CUSTOM_KEYS:{'apiDefault':0.6,'validWhen':{'ref':'profile','value':['wheelchair']}}", example = "0.03") @JsonProperty(PARAM_MAXIMUM_SLOPED_KERB) @@ -112,7 +111,7 @@ public class RequestProfileParamsRestrictions { @JsonIgnore private boolean hasMaxSlopedKerb = false; - @ApiModelProperty(name = PARAM_MAX_INCLINE, value = "Specifies the maximum incline as a percentage. `3`, `6` (default), `10`, `15." + + @Schema(name= PARAM_MAX_INCLINE, description = "Specifies the maximum incline as a percentage. `3`, `6` (default), `10`, `15." + "CUSTOM_KEYS:{'apiDefault':6,'validWhen':{'ref':'profile','value':['wheelchair']}}", example = "3") @JsonProperty(PARAM_MAX_INCLINE) @@ -120,7 +119,7 @@ public class RequestProfileParamsRestrictions { @JsonIgnore private boolean hasMaxIncline = false; - @ApiModelProperty(name = PARAM_MIN_WIDTH, value = "Specifies the minimum width of the footway in metres." + + @Schema(name= PARAM_MIN_WIDTH, description = "Specifies the minimum width of the footway in metres." + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['wheelchair']}}", example = "2.5") @JsonProperty(PARAM_MIN_WIDTH) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsWeightings.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsWeightings.java index f6b013a609..850bc23667 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsWeightings.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RequestProfileParamsWeightings.java @@ -18,10 +18,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; -@ApiModel(value = "Profile Weightings", parent = RequestProfileParams.class, description = "Describe additional weightings to be applied to edges on the routing.") +@Schema(name = "Profile Weightings", description = "Describe additional weightings to be applied to edges on the routing.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class RequestProfileParamsWeightings { public static final String PARAM_STEEPNESS_DIFFICULTY = "steepness_difficulty"; @@ -31,38 +30,38 @@ public class RequestProfileParamsWeightings { private static final String PARAM_CSV_COLUMN = "csv_column"; public static final String PARAM_SHADOW_INDEX = "shadow"; - @ApiModelProperty(name = PARAM_STEEPNESS_DIFFICULTY, value = "Specifies the fitness level for `cycling-*` profiles.\n" + + @Schema(name= PARAM_STEEPNESS_DIFFICULTY, description = "Specifies the fitness level for `cycling-*` profiles.\n" + "\n level: 0 = Novice, 1 = Moderate, 2 = Amateur, 3 = Pro. The prefered gradient increases with level. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['cycling-*']}}", example = "2") @JsonProperty(PARAM_STEEPNESS_DIFFICULTY) private Integer steepnessDifficulty; @JsonIgnore private boolean hasSteepnessDifficulty = false; - @ApiModelProperty(name = PARAM_GREEN_INDEX, value = "Specifies the Green factor for `foot-*` profiles.\n" + + @Schema(name= PARAM_GREEN_INDEX, description = "Specifies the Green factor for `foot-*` profiles.\n" + "\nfactor: Multiplication factor range from 0 to 1. 0 is the green routing base factor without multiplying it by the manual factor and is already different from normal routing. 1 will prefer ways through green areas over a shorter route. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['foot-*']}}", example = "0.4") @JsonProperty(PARAM_GREEN_INDEX) private Float greenIndex; @JsonIgnore private boolean hasGreenIndex = false; - @ApiModelProperty(name = PARAM_QUIETNESS, value = "Specifies the Quiet factor for foot-* profiles.\n" + + @Schema(name= PARAM_QUIETNESS, description = "Specifies the Quiet factor for foot-* profiles.\n" + "\nfactor: Multiplication factor range from 0 to 1. 0 is the quiet routing base factor without multiplying it by the manual factor and is already different from normal routing. 1 will prefer quiet ways over a shorter route. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['foot-*']}}", example = "0.8") @JsonProperty(PARAM_QUIETNESS) private Float quietIndex; @JsonIgnore private boolean hasQuietIndex = false; - @ApiModelProperty(name = PARAM_CSV_FACTOR, value="Specifies the factor of csv-column (range 0 to 1)", hidden = true) + @Schema(name = PARAM_CSV_FACTOR, description = "Specifies the factor of csv-column (range 0 to 1)", hidden = true) @JsonProperty(PARAM_CSV_FACTOR) private Float csvFactor; - @ApiModelProperty(name = PARAM_CSV_COLUMN, value="Specifies the csv column name", hidden = true) + @Schema(name = PARAM_CSV_COLUMN, description = "Specifies the csv column name", hidden = true) @JsonProperty(PARAM_CSV_COLUMN) private String csvColumn; @JsonIgnore private boolean hasCsv = false; - @ApiModelProperty(name = PARAM_SHADOW_INDEX, value = "Specifies the shadow factor for `foot-*` profiles.\n" + + @Schema(name= PARAM_SHADOW_INDEX, description = "Specifies the shadow factor for `foot-*` profiles.\n" + "\nfactor: Multiplication factor range from 0 to 1. 0 is the shadow routing base factor without multiplying it by the manual factor and is already different from normal routing. 1 will prefer ways through shadow areas over a shorter route. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['foot-*']}}", example = "0.4") @JsonProperty(PARAM_SHADOW_INDEX) private Float shadowIndex; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequest.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequest.java index 9245f8bb7c..2613271ecc 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequest.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequest.java @@ -16,8 +16,7 @@ package org.heigit.ors.api.requests.routing; import com.fasterxml.jackson.annotation.*; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.common.APIRequest; import org.heigit.ors.common.StatusCode; @@ -35,7 +34,7 @@ import java.util.List; import java.util.stream.Stream; -@ApiModel(value = "Directions Service", description = "The JSON body request sent to the routing service which defines options and parameters regarding the route to generate.") +@Schema(name = "Directions Service", description = "The JSON body request sent to the routing service which defines options and parameters regarding the route to generate.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class RouteRequest extends APIRequest { public static final String PARAM_COORDINATES = "coordinates"; @@ -70,7 +69,7 @@ public class RouteRequest extends APIRequest { public static final String PARAM_WALKING_TIME = "walking_time"; public static final String PARAM_IGNORE_TRANSFERS = "ignore_transfers"; - @ApiModelProperty(name = PARAM_COORDINATES, value = "The waypoints to use for the route as an array of `longitude/latitude` pairs in WGS 84 (EPSG:4326)", + @Schema(name= PARAM_COORDINATES, description = "The waypoints to use for the route as an array of `longitude/latitude` pairs in WGS 84 (EPSG:4326)", example = "[[8.681495,49.41461],[8.686507,49.41943],[8.687872,49.420318]]", required = true) @JsonProperty(PARAM_COORDINATES) @@ -78,36 +77,36 @@ public class RouteRequest extends APIRequest { //TODO (GTFS): We might need to make a bunch of these parameters only valid if profile pt is selected. - @ApiModelProperty(name = PARAM_PREFERENCE, - value = "Specifies the route preference. CUSTOM_KEYS:{'apiDefault':'recommended'}", + @Schema(name= PARAM_PREFERENCE, + description = "Specifies the route preference. CUSTOM_KEYS:{'apiDefault':'recommended'}", example = "recommended") @JsonProperty(value = PARAM_PREFERENCE) private APIEnums.RoutePreference routePreference; @JsonIgnore private boolean hasRoutePreference = false; - @ApiModelProperty(name = PARAM_FORMAT, hidden = true) + @Schema(name= PARAM_FORMAT, hidden = true) @JsonProperty(PARAM_FORMAT) private APIEnums.RouteResponseType responseType = APIEnums.RouteResponseType.JSON; - @ApiModelProperty(name = PARAM_UNITS, - value = "Specifies the distance unit. CUSTOM_KEYS:{'apiDefault':'m'}", + @Schema(name= PARAM_UNITS, + description = "Specifies the distance unit. CUSTOM_KEYS:{'apiDefault':'m'}", example = "m") @JsonProperty(value = PARAM_UNITS) private APIEnums.Units units; @JsonIgnore private boolean hasUnits = false; - @ApiModelProperty(name = PARAM_LANGUAGE, - value = "Language for the route instructions. CUSTOM_KEYS:{'apiDefault':'en'}", + @Schema(name= PARAM_LANGUAGE, + description = "Language for the route instructions. CUSTOM_KEYS:{'apiDefault':'en'}", example = "en") @JsonProperty(value = PARAM_LANGUAGE) private APIEnums.Languages language; @JsonIgnore private boolean hasLanguage = false; - @ApiModelProperty(name = PARAM_GEOMETRY, - value = "Specifies whether to return geometry. " + + @Schema(name= PARAM_GEOMETRY, + description = "Specifies whether to return geometry. " + "CUSTOM_KEYS:{'apiDefault':true, 'validWhen':{'ref':'format','value':['json']}}", example = "true") @JsonProperty(value = PARAM_GEOMETRY) @@ -115,24 +114,24 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasIncludeGeometry = false; - @ApiModelProperty(name = PARAM_INSTRUCTIONS, - value = "Specifies whether to return instructions. CUSTOM_KEYS:{'apiDefault':true}", + @Schema(name= PARAM_INSTRUCTIONS, + description = "Specifies whether to return instructions. CUSTOM_KEYS:{'apiDefault':true}", example = "true") @JsonProperty(value = PARAM_INSTRUCTIONS) private boolean includeInstructionsInResponse; @JsonIgnore private boolean hasIncludeInstructions = false; - @ApiModelProperty(name = PARAM_INSTRUCTIONS_FORMAT, - value = "Select html for more verbose instructions. CUSTOM_KEYS:{'apiDefault':'text'}", + @Schema(name= PARAM_INSTRUCTIONS_FORMAT, + description = "Select html for more verbose instructions. CUSTOM_KEYS:{'apiDefault':'text'}", example = "text") @JsonProperty(value = PARAM_INSTRUCTIONS_FORMAT) private APIEnums.InstructionsFormat instructionsFormat; @JsonIgnore private boolean hasInstructionsFormat = false; - @ApiModelProperty(name = PARAM_ROUNDABOUT_EXITS, - value = "Provides bearings of the entrance and all passed roundabout exits. Adds the `exit_bearings` array to the step object in the response. " + + @Schema(name= PARAM_ROUNDABOUT_EXITS, + description = "Provides bearings of the entrance and all passed roundabout exits. Adds the `exit_bearings` array to the step object in the response. " + "CUSTOM_KEYS:{'apiDefault':false}", example = "false") @JsonProperty(value = PARAM_ROUNDABOUT_EXITS) @@ -140,15 +139,15 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasIncludeRoundaboutExitInfo = false; - @ApiModelProperty(name = PARAM_ATTRIBUTES, - value = "List of route attributes", + @Schema(name= PARAM_ATTRIBUTES, + description = "List of route attributes", example = "[\"avgspeed\",\"percentage\"]") @JsonProperty(PARAM_ATTRIBUTES) private APIEnums.Attributes[] attributes; @JsonIgnore private boolean hasAttributes = false; - @ApiModelProperty(name = PARAM_MANEUVERS, value = "Specifies whether the maneuver object is included into the step object or not. " + + @Schema(name= PARAM_MANEUVERS, description = "Specifies whether the maneuver object is included into the step object or not. " + "CUSTOM_KEYS:{'apiDefault':false}", example = "false") @JsonProperty(value = PARAM_MANEUVERS) @@ -156,7 +155,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasIncludeManeuvers = false; - @ApiModelProperty(name = PARAM_RADII, value = "A list of maximum distances (measured in metres) that limit the search of nearby road segments to every given waypoint. " + + @Schema(name= PARAM_RADII, description = "A list of maximum distances (measured in metres) that limit the search of nearby road segments to every given waypoint. " + "The values must be greater than 0, the value of -1 specifies using the maximum possible search radius. The number of radiuses correspond to the number of waypoints. If only a single value is given, it will be applied to all waypoints.", example = "[200, -1, 30]") @JsonProperty(PARAM_RADII) @@ -165,13 +164,14 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasMaximumSearchRadii = false; - @ApiModelProperty(name = PARAM_BEARINGS, value = "Specifies a list of pairs (bearings and deviations) to filter the segments of the road network a waypoint can snap to. " + - "For example `bearings=[[45,10],[120,20]]`. \n" + - "Each pair is a comma-separated list that can consist of one or two float values, where the first value is the bearing and the second one is the allowed deviation from the bearing. " + - "The bearing can take values between `0` and `360` clockwise from true north. If the deviation is not set, then the default value of `100` degrees is used. " + - "The number of pairs must correspond to the number of waypoints.\n" + - "The number of bearings corresponds to the length of waypoints-1 or waypoints. If the bearing information for the last waypoint is given, then this will control the sector from which the destination waypoint may be reached. " + - "You can skip a bearing for a certain waypoint by passing an empty value for an array, e.g. `[30,20],[],[40,20]`. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':'cycling-*'}}", + @Schema(name= PARAM_BEARINGS, description = """ + Specifies a list of pairs (bearings and deviations) to filter the segments of the road network a waypoint can snap to. + "For example `bearings=[[45,10],[120,20]]`. + "Each pair is a comma-separated list that can consist of one or two float values, where the first value is the bearing and the second one is the allowed deviation from the bearing. + "The bearing can take values between `0` and `360` clockwise from true north. If the deviation is not set, then the default value of `100` degrees is used. + "The number of pairs must correspond to the number of waypoints. + "The number of bearings corresponds to the length of waypoints-1 or waypoints. If the bearing information for the last waypoint is given, then this will control the sector from which the destination waypoint may be reached. + "You can skip a bearing for a certain waypoint by passing an empty value for an array, e.g. `[30,20],[],[40,20]`. CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':'cycling-*'}}""", example = "[[30, 20], [], [40, 20]]" ) @JsonProperty(PARAM_BEARINGS) @@ -179,8 +179,8 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasBearings = false; - @ApiModelProperty(name = PARAM_CONTINUE_STRAIGHT, - value = "Forces the route to keep going straight at waypoints restricting uturns there even if it would be faster." + + @Schema(name= PARAM_CONTINUE_STRAIGHT, + description = "Forces the route to keep going straight at waypoints restricting uturns there even if it would be faster." + "CUSTOM_KEYS:{'apiDefault':'false'}", example = "false") @JsonProperty(value = PARAM_CONTINUE_STRAIGHT) @@ -188,46 +188,46 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasContinueStraightAtWaypoints = false; - @ApiModelProperty(name = PARAM_ELEVATION, - value = "Specifies whether to return elevation values for points. Please note that elevation also gets encoded for json response encoded polyline.", + @Schema(name= PARAM_ELEVATION, + description = "Specifies whether to return elevation values for points. Please note that elevation also gets encoded for json response encoded polyline.", example = "false") @JsonProperty(value = PARAM_ELEVATION) private boolean useElevation; @JsonIgnore private boolean hasUseElevation = false; - @ApiModelProperty(name = PARAM_EXTRA_INFO, - value = "The extra info items to include in the response", + @Schema(name= PARAM_EXTRA_INFO, + description = "The extra info items to include in the response", example = "[\"waytype\",\"surface\"]") @JsonProperty(PARAM_EXTRA_INFO) private APIEnums.ExtraInfo[] extraInfo; @JsonIgnore private boolean hasExtraInfo = false; - @ApiModelProperty(name = PARAM_OPTIMIZED, value = "Uses contraction hierarchies if available (false). " + + @Schema(name= PARAM_OPTIMIZED, description = "Uses contraction hierarchies if available (false). " + "CUSTOM_KEYS:{'apiDefault':true}", hidden = true) @JsonProperty(value = PARAM_OPTIMIZED) private boolean useContractionHierarchies; @JsonIgnore private boolean hasUseContractionHierarchies = false; - @ApiModelProperty(name = PARAM_OPTIONS, - value = "For advanced options formatted as json object. For structure refer to the [these examples](https://GIScience.github.io/openrouteservice/documentation/routing-options/Examples.html).", + @Schema(name= PARAM_OPTIONS, + description = "For advanced options formatted as json object. For structure refer to the [these examples](https://GIScience.github.io/openrouteservice/documentation/routing-options/Examples.html).", example = "{\"avoid_borders\":\"controlled\"}") @JsonProperty(PARAM_OPTIONS) private RouteRequestOptions routeOptions; @JsonIgnore private boolean hasRouteOptions = false; - @ApiModelProperty(name = PARAM_SUPPRESS_WARNINGS, - value = "Suppress warning messages in the response", + @Schema(name= PARAM_SUPPRESS_WARNINGS, + description = "Suppress warning messages in the response", example = "false") @JsonProperty(PARAM_SUPPRESS_WARNINGS) private boolean suppressWarnings; @JsonIgnore private boolean hasSuppressWarnings = false; - @ApiModelProperty(name = PARAM_SIMPLIFY_GEOMETRY, value = "Specifies whether to simplify the geometry. " + + @Schema(name= PARAM_SIMPLIFY_GEOMETRY, description = "Specifies whether to simplify the geometry. " + "Simplify geometry cannot be applied to routes with more than **one segment** and when `extra_info` is required." + "CUSTOM_KEYS:{'apiDefault':false}", example = "false") @@ -236,7 +236,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasSimplifyGeometry = false; - @ApiModelProperty(name = PARAM_SKIP_SEGMENTS, value = "Specifies the segments that should be skipped in the route calculation. " + + @Schema(name= PARAM_SKIP_SEGMENTS, description = "Specifies the segments that should be skipped in the route calculation. " + "A segment is the connection between two given coordinates and the counting starts with 1 for the connection between the first and second coordinate.", example = "[2,4]") @JsonProperty(PARAM_SKIP_SEGMENTS) @@ -244,15 +244,15 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasSkipSegments = false; - @ApiModelProperty(name = PARAM_ALTERNATIVE_ROUTES, - value = "Specifies whether alternative routes are computed, and parameters for the algorithm determining suitable alternatives.", + @Schema(name= PARAM_ALTERNATIVE_ROUTES, + description = "Specifies whether alternative routes are computed, and parameters for the algorithm determining suitable alternatives.", example = "{\"target_count\":2,\"weight_factor\":1.6}") @JsonProperty(PARAM_ALTERNATIVE_ROUTES) private RouteRequestAlternativeRoutes alternativeRoutes; @JsonIgnore private boolean hasAlternativeRoutes = false; - @ApiModelProperty(name = PARAM_DEPARTURE, value = "Departure date and time provided in local time zone" + + @Schema(name= PARAM_DEPARTURE, description = "Departure date and time provided in local time zone" + "CUSTOM_KEYS:{'validWhen':{'ref':'arrival','valueNot':['*']}}", example = "2020-01-31T12:45:00", hidden = true) @JsonProperty(PARAM_DEPARTURE) @@ -260,7 +260,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasDeparture = false; - @ApiModelProperty(name = PARAM_ARRIVAL, value = "Arrival date and time provided in local time zone" + + @Schema(name= PARAM_ARRIVAL, description = "Arrival date and time provided in local time zone" + "CUSTOM_KEYS:{'validWhen':{'ref':'departure','valueNot':['*']}}", example = "2020-01-31T13:15:00", hidden = true) @JsonProperty(PARAM_ARRIVAL) @@ -268,7 +268,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasArrival = false; - @ApiModelProperty(name = PARAM_MAXIMUM_SPEED, value = "The maximum speed specified by user." + + @Schema(name= PARAM_MAXIMUM_SPEED, description = "The maximum speed specified by user." + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['driving-*']}}", example = "90") @JsonProperty(PARAM_MAXIMUM_SPEED) @@ -280,7 +280,7 @@ public class RouteRequest extends APIRequest { * The following parameters are specific to public transport. * Other parameters public-transport accepts are coordinates and language. */ - @ApiModelProperty(name = PARAM_SCHEDULE, value = "If true, return a public transport schedule starting at for the next minutes." + + @Schema(name= PARAM_SCHEDULE, description = "If true, return a public transport schedule starting at for the next minutes." + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['public-transport']}, 'apiDefault': false}", example = "true") @JsonProperty(PARAM_SCHEDULE) @@ -288,7 +288,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasSchedule = false; - @ApiModelProperty(name = PARAM_SCHEDULE_DURATION, value = "The time window when requesting a public transport schedule." + + @Schema(name= PARAM_SCHEDULE_DURATION, description = "The time window when requesting a public transport schedule." + "CUSTOM_KEYS:{'validWhen':{'ref':'schedule','value':true}}", example = "PT30M") @JsonProperty(PARAM_SCHEDULE_DURATION) @@ -296,7 +296,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasScheduleDuration = false; - @ApiModelProperty(name = PARAM_SCHEDULE_ROWS, value = "The maximum amount of entries that should be returned when requesting a schedule." + + @Schema(name= PARAM_SCHEDULE_ROWS, description = "The maximum amount of entries that should be returned when requesting a schedule." + "CUSTOM_KEYS:{'validWhen':{'ref':'schedule','value':true}}", example = "3") @JsonProperty(PARAM_SCHEDULE_ROWS) @@ -304,7 +304,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasScheduleRows = false; - @ApiModelProperty(name = PARAM_WALKING_TIME, value = "Maximum duration for walking access and egress of public transport." + + @Schema(name= PARAM_WALKING_TIME, description = "Maximum duration for walking access and egress of public transport." + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['public-transport']}, 'apiDefault': 'PT15M'}", example = "PT30M") @JsonProperty(PARAM_WALKING_TIME) @@ -312,7 +312,7 @@ public class RouteRequest extends APIRequest { @JsonIgnore private boolean hasWalkingTime = false; - @ApiModelProperty(name = PARAM_IGNORE_TRANSFERS, value = "Specifies if transfers as criterion should be ignored." + + @Schema(name= PARAM_IGNORE_TRANSFERS, description = "Specifies if transfers as criterion should be ignored." + "CUSTOM_KEYS:{'validWhen':{'ref':'profile','value':['public-transport']}, 'apiDefault': false}", example = "true") @JsonProperty(PARAM_IGNORE_TRANSFERS) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestAlternativeRoutes.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestAlternativeRoutes.java index 3517c1deb3..967a9a3c23 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestAlternativeRoutes.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestAlternativeRoutes.java @@ -18,29 +18,28 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; -@ApiModel(value = "Alternative Routes", parent = RouteRequestOptions.class, description = "Specifies whether alternative routes are computed, and parameters for the algorithm determining suitable alternatives.") +@Schema(name = "Alternative Routes", description = "Specifies whether alternative routes are computed, and parameters for the algorithm determining suitable alternatives.") @JsonInclude(JsonInclude.Include.NON_EMPTY) public class RouteRequestAlternativeRoutes { public static final String PARAM_TARGET_COUNT = "target_count"; public static final String PARAM_WEIGHT_FACTOR = "weight_factor"; public static final String PARAM_SHARE_FACTOR = "share_factor"; - @ApiModelProperty(name = PARAM_TARGET_COUNT, value = "Target number of alternative routes to compute. Service returns up to this number of routes that fulfill the share-factor and weight-factor constraints.", example = "2") + @Schema(name= PARAM_TARGET_COUNT, description = "Target number of alternative routes to compute. Service returns up to this number of routes that fulfill the share-factor and weight-factor constraints.", example = "2") @JsonProperty(PARAM_TARGET_COUNT) private Integer targetCount; @JsonIgnore private boolean hasTargetCount = false; - @ApiModelProperty(name = PARAM_WEIGHT_FACTOR, value = "Maximum factor by which route weight may diverge from the optimal route. The default value of 1.4 means alternatives can be up to 1.4 times longer (costly) than the optimal route.", example = "1.4") + @Schema(name= PARAM_WEIGHT_FACTOR, description = "Maximum factor by which route weight may diverge from the optimal route. The default value of 1.4 means alternatives can be up to 1.4 times longer (costly) than the optimal route.", example = "1.4") @JsonProperty(PARAM_WEIGHT_FACTOR) private Double weightFactor; @JsonIgnore private boolean hasWeightFactor = false; - @ApiModelProperty(name = PARAM_SHARE_FACTOR, value = "Maximum fraction of the route that alternatives may share with the optimal route. The default value of 0.6 means alternatives can share up to 60% of path segments with the optimal route.", example = "0.6") + @Schema(name= PARAM_SHARE_FACTOR, description = "Maximum fraction of the route that alternatives may share with the optimal route. The default value of 0.6 means alternatives can share up to 60% of path segments with the optimal route.", example = "0.6") @JsonProperty(PARAM_SHARE_FACTOR) private Double shareFactor; @JsonIgnore diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestOptions.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestOptions.java index 70cd116427..cfff0e04f5 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestOptions.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestOptions.java @@ -18,18 +18,15 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; - +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.RequestOptions; -import org.heigit.ors.isochrones.IsochroneRequest; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -@ApiModel(value = "Route Options", description = "Advanced options for routing", subTypes = {RouteRequest.class, IsochroneRequest.class}) +@Schema(name = "Route Options", description = "Advanced options for routing", subTypes = {RouteRequestAlternativeRoutes.class, RequestProfileParams.class, RouteRequestRoundTripOptions.class}) @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class RouteRequestOptions extends RequestOptions { public static final String PARAM_ROUND_TRIP_OPTIONS = "round_trip"; - @ApiModelProperty(name = PARAM_ROUND_TRIP_OPTIONS, value = "Options to be applied on round trip routes.", + @Schema(name= PARAM_ROUND_TRIP_OPTIONS, description = "Options to be applied on round trip routes.", example = "{\"length\":10000,\"points\":5}") @JsonProperty(PARAM_ROUND_TRIP_OPTIONS) private RouteRequestRoundTripOptions roundTripOptions; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestRoundTripOptions.java b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestRoundTripOptions.java index 06c703c646..d85d6bc83c 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestRoundTripOptions.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/requests/routing/RouteRequestRoundTripOptions.java @@ -18,31 +18,30 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; -@ApiModel(value = "Round Trip Route Options", parent = RouteRequestOptions.class, description = "Specifies the parameters for generating round trip routes.") +@Schema(name = "Round Trip Route Options", description = "Specifies the parameters for generating round trip routes.") @JsonInclude(JsonInclude.Include.NON_EMPTY) public class RouteRequestRoundTripOptions { public static final String PARAM_LENGTH = "length"; public static final String PARAM_POINTS = "points"; public static final String PARAM_SEED = "seed"; - @ApiModelProperty(name = PARAM_LENGTH, value = "The target length of the route in `m` (note that this is a preferred value, but results may be different).", + @Schema(name= PARAM_LENGTH, description = "The target length of the route in `m` (note that this is a preferred value, but results may be different).", example = "10000") @JsonProperty(PARAM_LENGTH) private Float length; @JsonIgnore private boolean hasLength = false; - @ApiModelProperty(name = PARAM_POINTS, value = "The number of points to use on the route. Larger values create more circular routes.", + @Schema(name= PARAM_POINTS, description = "The number of points to use on the route. Larger values create more circular routes.", example = "5") @JsonProperty(PARAM_POINTS) private Integer points; @JsonIgnore private boolean hasPoints = false; - @ApiModelProperty(name = PARAM_SEED, value = "A seed to use for adding randomisation to the overall direction of the generated route", + @Schema(name= PARAM_SEED, description = "A seed to use for adding randomisation to the overall direction of the generated route", example = "1") @JsonProperty(PARAM_SEED) private Long seed; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityLocation.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityLocation.java index 768d164584..2289624451 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityLocation.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityLocation.java @@ -2,21 +2,21 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.util.FormatUtility; +import org.locationtech.jts.geom.Coordinate; import java.util.Map; public class JsonCentralityLocation { protected static final int COORDINATE_DECIMAL_PLACES = 6; - @ApiModelProperty(value = "Id of the corresponding node in the graph", example = "1") + @Schema(description = "Id of the corresponding node in the graph", example = "1") @JsonProperty(value = "nodeId") @JsonFormat(shape = JsonFormat.Shape.NUMBER) protected Integer nodeId; - @ApiModelProperty(value = "{longitude},{latitude} coordinates of the closest accessible point on the routing graph", + @Schema(description = "{longitude},{latitude} coordinates of the closest accessible point on the routing graph", example = "[8.678962, 49.40783]") @JsonProperty(value = "coord") @JsonFormat(shape = JsonFormat.Shape.ARRAY) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityResponse.java index cae0e8d487..25312f26c8 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonCentralityResponse.java @@ -2,19 +2,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModel; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.responses.centrality.CentralityResponse; import org.heigit.ors.api.responses.routing.json.JSONWarning; import org.heigit.ors.centrality.CentralityResult; import org.heigit.ors.centrality.CentralityWarning; import org.heigit.ors.common.Pair; +import org.locationtech.jts.geom.Coordinate; import java.util.ArrayList; import java.util.List; import java.util.Map; -@ApiModel(description = "The Centrality Response contains centrality values for nodes or edges in the requested BBox") +@Schema(description = "The Centrality Response contains centrality values for nodes or edges in the requested BBox") @JsonInclude(JsonInclude.Include.NON_NULL) public class JsonCentralityResponse extends CentralityResponse { diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonEdgeScore.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonEdgeScore.java index 7da35d212f..54d8dd8b5a 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonEdgeScore.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonEdgeScore.java @@ -2,23 +2,23 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.common.Pair; import java.util.Map; public class JsonEdgeScore { - @ApiModelProperty(value = "Id of the start point of the edge", example = "1") + @Schema(description = "Id of the start point of the edge", example = "1") @JsonProperty(value = "fromId") @JsonFormat(shape = JsonFormat.Shape.NUMBER_INT) protected Integer fromId; - @ApiModelProperty(value = "Id of the end point of the edge", example = "2") + @Schema(description = "Id of the end point of the edge", example = "2") @JsonProperty(value = "toId") @JsonFormat(shape = JsonFormat.Shape.NUMBER_INT) protected Integer toId; - @ApiModelProperty(value = "Centrality Score of the corresponding edge in the given bounding box", + @Schema(description = "Centrality Score of the corresponding edge in the given bounding box", example = "123.45") @JsonProperty(value = "score") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonNodeScore.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonNodeScore.java index 0305a4c23b..70f5fde69b 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonNodeScore.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/centrality/json/JsonNodeScore.java @@ -2,17 +2,17 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import java.util.Map; public class JsonNodeScore { - @ApiModelProperty(value = "Id of the corresponding node in the graph", example = "1") + @Schema(description = "Id of the corresponding node in the graph", example = "1") @JsonProperty(value = "nodeId") @JsonFormat(shape = JsonFormat.Shape.NUMBER_INT) protected Integer nodeId; - @ApiModelProperty(value = "Centrality Score of the corresponding node in the given bounding box", + @Schema(description = "Centrality Score of the corresponding node in the given bounding box", example = "123.45") @JsonProperty(value = "score") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java index 1d988509e3..5e8a5f0e94 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdge.java @@ -2,23 +2,23 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.common.Pair; import java.util.Map; public class JsonEdge { - @ApiModelProperty(value = "Id of the start point of the edge", example = "1") + @Schema(description = "Id of the start point of the edge", example = "1") @JsonProperty(value = "fromId") @JsonFormat(shape = JsonFormat.Shape.NUMBER_INT) protected Integer fromId; - @ApiModelProperty(value = "Id of the end point of the edge", example = "2") + @Schema(description = "Id of the end point of the edge", example = "2") @JsonProperty(value = "toId") @JsonFormat(shape = JsonFormat.Shape.NUMBER_INT) protected Integer toId; - @ApiModelProperty(value = "Weight of the corresponding edge in the given bounding box", + @Schema(description = "Weight of the corresponding edge in the given bounding box", example = "123.45") @JsonProperty(value = "weight") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdgeExtra.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdgeExtra.java index c22c85319a..2ab2452f75 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdgeExtra.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonEdgeExtra.java @@ -2,21 +2,19 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.common.Pair; -import org.heigit.ors.util.FormatUtility; import java.util.Map; public class JsonEdgeExtra { - @ApiModelProperty(value = "Id of the corresponding edge in the graph", example = "1") + @Schema(description = "Id of the corresponding edge in the graph", example = "1") @JsonProperty(value = "edgeId") @JsonFormat(shape = JsonFormat.Shape.NUMBER) protected String nodeId; - @ApiModelProperty(value = "Extra info stored on the edge", + @Schema(description = "Extra info stored on the edge", example = "{\"surface_quality_known\" : \"true\"}") @JsonProperty(value = "extra") @JsonFormat(shape = JsonFormat.Shape.ANY) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonExportResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonExportResponse.java index 96f3f1a392..aac5cf6355 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonExportResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonExportResponse.java @@ -2,19 +2,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModel; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.responses.export.ExportResponse; import org.heigit.ors.api.responses.routing.json.JSONWarning; -import org.heigit.ors.export.ExportResult; import org.heigit.ors.common.Pair; +import org.heigit.ors.export.ExportResult; import org.heigit.ors.export.ExportWarning; +import org.locationtech.jts.geom.Coordinate; import java.util.ArrayList; import java.util.List; import java.util.Map; -@ApiModel(description = "The Export Response contains nodes and edge weights from the requested BBox") +@Schema(description = "The Export Response contains nodes and edge weights from the requested BBox") @JsonInclude(JsonInclude.Include.NON_NULL) public class JsonExportResponse extends ExportResponse { diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonNode.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonNode.java index 2c405ff925..66d810e8fa 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonNode.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/export/json/JsonNode.java @@ -2,21 +2,21 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.util.FormatUtility; +import org.locationtech.jts.geom.Coordinate; import java.util.Map; public class JsonNode { protected static final int COORDINATE_DECIMAL_PLACES = 6; - @ApiModelProperty(value = "Id of the corresponding node in the graph", example = "1") + @Schema(description = "Id of the corresponding node in the graph", example = "1") @JsonProperty(value = "nodeId") @JsonFormat(shape = JsonFormat.Shape.NUMBER) protected Integer nodeId; - @ApiModelProperty(value = "{longitude},{latitude} coordinates of the closest accessible point on the routing graph", + @Schema(description = "{longitude},{latitude} coordinates of the closest accessible point on the routing graph", example = "[8.678962, 49.40783]") @JsonProperty(value = "location") @JsonFormat(shape = JsonFormat.Shape.ARRAY) diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/IsochronesResponseInfo.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/IsochronesResponseInfo.java index f3510ea14b..4cf1fe209c 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/IsochronesResponseInfo.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/IsochronesResponseInfo.java @@ -18,8 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.graphhopper.util.Helper; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.isochrones.IsochronesRequest; import org.heigit.ors.api.util.SystemMessage; import org.heigit.ors.config.AppConfig; @@ -27,35 +26,35 @@ import org.heigit.ors.util.AppInfo; import org.json.JSONObject; -@ApiModel(value = "IsochronesResponseInfo", description = "Information about the request") +@Schema(name = "IsochronesResponseInfo", description = "Information about the request") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class IsochronesResponseInfo { - @ApiModelProperty(value = "ID of the request (as passed in by the query)", example = "request123") + @Schema(description = "ID of the request (as passed in by the query)", example = "request123") @JsonProperty("id") private String id; - @ApiModelProperty(value = "Copyright and attribution information", example = "openrouteservice.org | OpenStreetMap contributors") + @Schema(description = "Copyright and attribution information", example = "openrouteservice.org | OpenStreetMap contributors") @JsonProperty("attribution") private String attribution; - @ApiModelProperty(value = "The MD5 hash of the OSM planet file that was used for generating graphs", example = "c0327ba6") + @Schema(description = "The MD5 hash of the OSM planet file that was used for generating graphs", example = "c0327ba6") @JsonProperty("osm_file_md5_hash") private String osmFileMD5Hash; - @ApiModelProperty(value = "The service that was requested", example = "isochrones") + @Schema(description = "The service that was requested", example = "isochrones") @JsonProperty("service") private final String service; - @ApiModelProperty(value = "Time that the request was made (UNIX Epoch time)", example = "1549549847974") + @Schema(description = "Time that the request was made (UNIX Epoch time)", example = "1549549847974") @JsonProperty("timestamp") private final long timeStamp; - @ApiModelProperty(value = "The information that was used for generating the isochrones") + @Schema(description = "The information that was used for generating the isochrones") @JsonProperty("query") private final IsochronesRequest request; - @ApiModelProperty(value = "Information about the isochrones service") + @Schema(description = "Information about the isochrones service") @JsonProperty("engine") private final EngineInfo engineInfo; - @ApiModelProperty(value = "System message", example ="A message string configured in the service") + @Schema(description = "System message", example ="A message string configured in the service") @JsonProperty("system_message") private final String systemMessage; @@ -83,15 +82,15 @@ public void setGraphDate(String graphDate) { engineInfo.setGraphDate(graphDate); } - @ApiModel(description = "Information about the version of the openrouteservice that was used to generate the isochrones") + @Schema(description = "Information about the version of the openrouteservice that was used to generate the isochrones") private class EngineInfo { - @ApiModelProperty(value = "The backend version of the openrouteservice that was queried", example = "5.0") + @Schema(description = "The backend version of the openrouteservice that was queried", example = "5.0") @JsonProperty("version") private final String version; - @ApiModelProperty(value = "The date that the service was last updated", example = "2019-02-07T14:28:11Z") + @Schema(description = "The date that the service was last updated", example = "2019-02-07T14:28:11Z") @JsonProperty("build_date") private final String buildDate; - @ApiModelProperty(value = "The date that the graph data was last updated", example = "2019-02-07T14:28:11Z") + @Schema(description = "The date that the graph data was last updated", example = "2019-02-07T14:28:11Z") @JsonProperty("graph_date") private String graphDate; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneBase.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneBase.java index 56f8aaa13c..9cc51f6b74 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneBase.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneBase.java @@ -17,11 +17,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.Polygon; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.geojson.GeometryJSON; -import io.swagger.annotations.ApiModelProperty; import org.json.simple.JSONObject; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.Polygon; public abstract class GeoJSONIsochroneBase { @JsonProperty("type") @@ -30,7 +30,7 @@ public abstract class GeoJSONIsochroneBase { @JsonIgnore abstract Geometry getIsochroneGeometry(); - @ApiModelProperty(dataType = "org.json.simple.JSONObject") + @Schema(implementation = JSONObject.class) @JsonProperty("geometry") public JSONObject getGeometry() { JSONObject geoJson = new JSONObject(); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneProperties.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneProperties.java index 0877815b2d..b7800d1209 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneProperties.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochroneProperties.java @@ -2,38 +2,39 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.common.AttributeValue; import org.heigit.ors.isochrones.Isochrone; -import io.swagger.annotations.ApiModelProperty; +import org.locationtech.jts.geom.Coordinate; + @JsonInclude(JsonInclude.Include.NON_EMPTY) public class GeoJSONIsochroneProperties { - @ApiModelProperty(value = "Id of the isochrone based on the position in the `locations` query-parameter. Every location comprises its own group of polygons.", example ="1") + @Schema(description = "Id of the isochrone based on the position in the `locations` query-parameter. Every location comprises its own group of polygons.", example ="1") @JsonProperty(value = "group_index") private final Integer groupIndex; - @ApiModelProperty(value = "The range value of this isochrone/equidistant in seconds/meters.", example = "90") + @Schema(description = "The range value of this isochrone/equidistant in seconds/meters.", example = "90") @JsonProperty("value") private final Double value; - @ApiModelProperty(value = "The coordinates of the specific analysis location.", example = "[8.676441,49.411648]") + @Schema(description = "The coordinates of the specific analysis location.", example = "[8.676441,49.411648]") @JsonProperty("center") private final Double[] center; - @ApiModelProperty(value = "Area of the polygon in square meters (for attributes=area). CUSTOM_KEYS:{'validWhen':{'ref':'attributes','containsValue':'area'}}", + @Schema(description = "Area of the polygon in square meters (for attributes=area). CUSTOM_KEYS:{'validWhen':{'ref':'attributes','containsValue':'area'}}", example = "567.827") @JsonProperty("area") private Double area; - @ApiModelProperty(value = "Returns a reachability score between 0 and 1 (for attributes=reachfactor). " + + @Schema(description = "Returns a reachability score between 0 and 1 (for attributes=reachfactor). " + "As the maximum reachfactor would be achieved by travelling as the crow flies at maximum speed in a vacuum " + "without obstacles, naturally it can never be 1. The availability of motorways however produces a higher score over normal roads.", example = "0.56") @JsonProperty("reachfactor") private Double reachfactor; - @ApiModelProperty(value = "Total population of the polygon (for attributes=total_pop). CUSTOM_KEYS:{'validWhen':{'ref':'attributes','containsValue':'total_pop'}}", + @Schema(description = "Total population of the polygon (for attributes=total_pop). CUSTOM_KEYS:{'validWhen':{'ref':'attributes','containsValue':'total_pop'}}", example = "562789") @JsonProperty(value = "total_pop") private Double totalPop; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochronesResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochronesResponse.java index b744c32741..a129c99320 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochronesResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/isochrones/geojson/GeoJSONIsochronesResponse.java @@ -18,8 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.graphhopper.util.shapes.BBox; -import org.locationtech.jts.geom.Envelope; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.isochrones.IsochronesRequest; import org.heigit.ors.api.responses.common.boundingbox.BoundingBoxFactory; import org.heigit.ors.api.responses.isochrones.IsochronesResponse; @@ -31,6 +30,7 @@ import org.heigit.ors.isochrones.IsochroneUtility; import org.heigit.ors.isochrones.IsochronesIntersection; import org.heigit.ors.util.GeomUtility; +import org.locationtech.jts.geom.Envelope; import java.util.ArrayList; import java.util.List; @@ -41,7 +41,7 @@ public class GeoJSONIsochronesResponse extends IsochronesResponse { @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_NULL) - @ApiModelProperty(value = "Bounding box that covers all returned isochrones", example = "[49.414057, 8.680894, 49.420514, 8.690123]") + @Schema(description = "Bounding box that covers all returned isochrones", example = "[49.414057, 8.680894, 49.420514, 8.690123]") public double[] getBBoxAsArray() { return bbox.getAsArray(); } diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/MatrixResponseInfo.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/MatrixResponseInfo.java index fec6ffb2fa..498c87bbaa 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/MatrixResponseInfo.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/MatrixResponseInfo.java @@ -18,44 +18,43 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.graphhopper.util.Helper; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.matrix.MatrixRequest; import org.heigit.ors.api.util.SystemMessage; import org.heigit.ors.config.AppConfig; import org.heigit.ors.config.RoutingServiceSettings; import org.heigit.ors.util.AppInfo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.json.JSONObject; -@ApiModel(description = "Information about the request") +@Schema(description = "Information about the request") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class MatrixResponseInfo { - @ApiModelProperty(value = "ID of the request (as passed in by the query)", example = "request123") + @Schema(description = "ID of the request (as passed in by the query)", example = "request123") @JsonProperty("id") private String id; - @ApiModelProperty(value = "Copyright and attribution information", example = "openrouteservice.org, OpenStreetMap contributors") + @Schema(description = "Copyright and attribution information", example = "openrouteservice.org, OpenStreetMap contributors") @JsonProperty("attribution") private String attribution; - @ApiModelProperty(value = "The MD5 hash of the OSM planet file that was used for generating graphs", example = "c0327ba6") + @Schema(description = "The MD5 hash of the OSM planet file that was used for generating graphs", example = "c0327ba6") @JsonProperty("osm_file_md5_hash") private String osmFileMD5Hash; - @ApiModelProperty(value = "The service that was requested", example = "matrix") + @Schema(description = "The service that was requested", example = "matrix") @JsonProperty("service") private final String service; - @ApiModelProperty(value = "Time that the request was made (UNIX Epoch time)", example = "1549549847974") + @Schema(description = "Time that the request was made (UNIX Epoch time)", example = "1549549847974") @JsonProperty("timestamp") private final long timeStamp; - @ApiModelProperty(value = "The information that was used for generating the matrix") + @Schema(description = "The information that was used for generating the matrix") @JsonProperty("query") private final MatrixRequest request; - @ApiModelProperty(value = "Information about the routing service") + @Schema(description = "Information about the routing service") @JsonProperty("engine") private final EngineInfo engineInfo; - @ApiModelProperty(value = "System message", example ="A message string configured in the service") + @Schema(description = "System message", example ="A message string configured in the service") @JsonProperty("system_message") private final String systemMessage; @@ -82,15 +81,15 @@ public void setGraphDate(String graphDate) { engineInfo.setGraphDate(graphDate); } - @ApiModel(description = "Information about the version of the openrouteservice that was used to generate the matrix") + @Schema(description = "Information about the version of the openrouteservice that was used to generate the matrix") private class EngineInfo { - @ApiModelProperty(value = "The backend version of the openrouteservice that was queried", example = "5.0") + @Schema(description = "The backend version of the openrouteservice that was queried", example = "5.0") @JsonProperty("version") private final String version; - @ApiModelProperty(value = "The date that the service was last updated", example = "2019-02-07T14:28:11Z") + @Schema(description = "The date that the service was last updated", example = "2019-02-07T14:28:11Z") @JsonProperty("build_date") private final String buildDate; - @ApiModelProperty(value = "The date that the graph data was last updated", example = "2019-02-07T14:28:11Z") + @Schema(description = "The date that the graph data was last updated", example = "2019-02-07T14:28:11Z") @JsonProperty("graph_date") private String graphDate; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONIndividualMatrixResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONIndividualMatrixResponse.java index c2b6b3dbc1..60966a9baa 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONIndividualMatrixResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONIndividualMatrixResponse.java @@ -17,31 +17,30 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.matrix.MatrixRequest; import org.heigit.ors.matrix.MatrixMetricsType; import org.heigit.ors.matrix.MatrixResult; import org.heigit.ors.util.FormatUtility; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.util.List; @JsonInclude(JsonInclude.Include.NON_DEFAULT) -@ApiModel(value = "JSONIndividualMatrixResponse", description = "An individual JSON based route created by the service") +@Schema(name = "JSONIndividualMatrixResponse", description = "An individual JSON based route created by the service") public class JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { - @ApiModelProperty(value = "The durations of the matrix calculations.", example = "[[0,25],[25,0]]") + @Schema(description = "The durations of the matrix calculations.", example = "[[0,25],[25,0]]") @JsonProperty("durations") private Double[][] durations; - @ApiModelProperty(value = "The distances of the matrix calculations.", example = "[[0,0.25],[0.25,0]]") + @Schema(description = "The distances of the matrix calculations.", example = "[[0,0.25],[0.25,0]]") @JsonProperty("distances") private Double[][] distances; - @ApiModelProperty(value = "The individual destinations of the matrix calculations.") + @Schema(description = "The individual destinations of the matrix calculations.") @JsonProperty("destinations") private List destinations; - @ApiModelProperty(value = "The individual sources of the matrix calculations.") + @Schema(description = "The individual sources of the matrix calculations.") @JsonProperty("sources") private List sources; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONLocation.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONLocation.java index 10debb9a0e..fed74dabe4 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONLocation.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONLocation.java @@ -17,29 +17,30 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.matrix.ResolvedLocation; import org.heigit.ors.util.FormatUtility; -import io.swagger.annotations.ApiModelProperty; +import org.locationtech.jts.geom.Coordinate; + public class JSONLocation { protected static final int COORDINATE_DECIMAL_PLACES = 6; private static final int SNAPPED_DISTANCE_DECIMAL_PLACES = 2; - @ApiModelProperty(value = "{longitude},{latitude} coordinates of the closest accessible point on the routing graph", + @Schema(description = "{longitude},{latitude} coordinates of the closest accessible point on the routing graph", example = "[8.678962, 49.40783]") @JsonProperty(value = "location") @JsonFormat(shape = JsonFormat.Shape.ARRAY) protected Coordinate location; - @ApiModelProperty(value = "Name of the street the closest accessible point is situated on. Only for `resolve_locations=true` and only if name is available." + + @Schema(description = "Name of the street the closest accessible point is situated on. Only for `resolve_locations=true` and only if name is available." + "CUSTOM_KEYS:{'validWhen':{'ref':'resolve_locations','value':true}}", example = "Bergheimer Straße") @JsonProperty(value = "name") @JsonFormat(shape = JsonFormat.Shape.STRING) protected String name; - @ApiModelProperty(value = "Distance between the `source/destination` Location and the used point on the routing graph.", example = "1.2") + @Schema(description = "Distance between the `source/destination` Location and the used point on the routing graph.", example = "1.2") @JsonProperty(value = "snapped_distance") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.2d") private final Double snappedDistance; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONMatrixResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONMatrixResponse.java index 28b871b82e..1b845b29a8 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONMatrixResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/matrix/json/JSONMatrixResponse.java @@ -17,14 +17,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonUnwrapped; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.matrix.MatrixRequest; import org.heigit.ors.api.responses.matrix.MatrixResponse; import org.heigit.ors.api.responses.matrix.MatrixResponseInfo; import org.heigit.ors.matrix.MatrixResult; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -@ApiModel(description = "The Matrix Response contains one matrix for each specified `metrics` value.") +@Schema(description = "The Matrix Response contains one matrix for each specified `metrics` value.") public class JSONMatrixResponse extends MatrixResponse { public JSONMatrixResponse(MatrixResult result, MatrixRequest request) { super(result, request); @@ -38,7 +37,7 @@ public JSONIndividualMatrixResponse getMatrix() { } @JsonProperty("metadata") - @ApiModelProperty("Information about the service and request") + @Schema(description = "Information about the service and request") public MatrixResponseInfo getInfo() { return responseInformation; } diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/RouteResponseInfo.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/RouteResponseInfo.java index 17664c274f..447928a1a6 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/RouteResponseInfo.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/RouteResponseInfo.java @@ -18,44 +18,43 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.graphhopper.util.Helper; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.api.util.SystemMessage; import org.heigit.ors.config.AppConfig; import org.heigit.ors.config.RoutingServiceSettings; import org.heigit.ors.util.AppInfo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.json.JSONObject; -@ApiModel(description = "Information about the request") +@Schema(description = "Information about the request") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class RouteResponseInfo { - @ApiModelProperty(value = "ID of the request (as passed in by the query)", example = "request123") + @Schema(description = "ID of the request (as passed in by the query)", example = "request123") @JsonProperty("id") private String id; - @ApiModelProperty(value = "Copyright and attribution information", example = "openrouteservice.org | OpenStreetMap contributors") + @Schema(description = "Copyright and attribution information", example = "openrouteservice.org | OpenStreetMap contributors") @JsonProperty("attribution") private String attribution; - @ApiModelProperty(value = "The MD5 hash of the OSM planet file that was used for generating graphs", example ="c0327ba6") + @Schema(description = "The MD5 hash of the OSM planet file that was used for generating graphs", example ="c0327ba6") @JsonProperty("osm_file_md5_hash") private String osmFileMD5Hash; - @ApiModelProperty(value = "The service that was requested", example = "routing") + @Schema(description = "The service that was requested", example = "routing") @JsonProperty("service") private final String service; - @ApiModelProperty(value = "Time that the request was made (UNIX Epoch time)",example = "1549549847974") + @Schema(description = "Time that the request was made (UNIX Epoch time)",example = "1549549847974") @JsonProperty("timestamp") private final long timeStamp; - @ApiModelProperty(value = "The information that was used for generating the route") + @Schema(description = "The information that was used for generating the route") @JsonProperty("query") private final RouteRequest request; - @ApiModelProperty(value = "Information about the routing service") + @Schema(description = "Information about the routing service") @JsonProperty("engine") private final EngineInfo engineInfo; - @ApiModelProperty(value = "System message", example ="A message string configured in the service") + @Schema(description = "System message", example ="A message string configured in the service") @JsonProperty("system_message") private final String systemMessage; @@ -83,15 +82,15 @@ public void setGraphDate(String graphDate) { engineInfo.setGraphDate(graphDate); } - @ApiModel(description = "Information about the version of the openrouteservice that was used to generate the route") + @Schema(description = "Information about the version of the openrouteservice that was used to generate the route") private class EngineInfo { - @ApiModelProperty(value = "The backend version of the openrouteservice that was queried", example = "5.0") + @Schema(description = "The backend version of the openrouteservice that was queried", example = "5.0") @JsonProperty("version") private final String version; - @ApiModelProperty(value = "The date that the service was last updated", example = "2019-02-07T14:28:11Z") + @Schema(description = "The date that the service was last updated", example = "2019-02-07T14:28:11Z") @JsonProperty("build_date") private final String buildDate; - @ApiModelProperty(value = "The date that the graph data was last updated", example = "2019-02-07T14:28:11Z") + @Schema(description = "The date that the graph data was last updated", example = "2019-02-07T14:28:11Z") @JsonProperty("graph_date") private String graphDate; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONIndividualRouteResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONIndividualRouteResponse.java index ab0ec91658..d0a1339dd9 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONIndividualRouteResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONIndividualRouteResponse.java @@ -17,13 +17,13 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.api.responses.routing.json.JSONBasedIndividualRouteResponse; import org.heigit.ors.api.responses.routing.json.JSONSegment; import org.heigit.ors.exceptions.StatusCodeException; import org.heigit.ors.geojson.GeometryJSON; import org.heigit.ors.routing.RouteResult; -import io.swagger.annotations.ApiModelProperty; import org.json.simple.JSONObject; import java.util.List; @@ -45,7 +45,7 @@ public GeoJSONIndividualRouteResponse(RouteResult routeResult, RouteRequest requ properties = new GeoJSONSummary(routeResult, segments, extras, this.includeElevation, this.isPtRequest, constructLegs(routeResult)); } - @ApiModelProperty(dataType = "org.json.simple.JSONObject") + @Schema(implementation = JSONObject.class) @JsonProperty("geometry") public JSONObject getGeometry() { JSONObject geoJson = new JSONObject(); diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONRouteResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONRouteResponse.java index 09d00dea1f..9d1a5470bf 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONRouteResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONRouteResponse.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.graphhopper.util.shapes.BBox; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.api.responses.common.boundingbox.BoundingBoxFactory; import org.heigit.ors.api.responses.routing.IndividualRouteResponse; @@ -26,7 +27,6 @@ import org.heigit.ors.exceptions.StatusCodeException; import org.heigit.ors.routing.RouteResult; import org.heigit.ors.util.GeomUtility; -import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; @@ -37,7 +37,7 @@ public class GeoJSONRouteResponse extends RouteResponse { @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_EMPTY) - @ApiModelProperty(value = "Bounding box that covers all returned routes", example = "[49.414057, 8.680894, 49.420514, 8.690123]") + @Schema(description = "Bounding box that covers all returned routes", example = "[49.414057, 8.680894, 49.420514, 8.690123]") public double[] getBBoxAsArray() { return bbox.getAsArray(); } diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONSummary.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONSummary.java index 1db5ef4c83..647a55f926 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONSummary.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/geojson/GeoJSONSummary.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.responses.routing.json.JSONExtra; import org.heigit.ors.api.responses.routing.json.JSONLeg; import org.heigit.ors.api.responses.routing.json.JSONSegment; @@ -43,11 +43,11 @@ public class GeoJSONSummary extends JSONSummary { @JsonProperty("legs") private final List legs; private final List warnings; - @ApiModelProperty(value = "Departure date and time" + + @Schema(description = "Departure date and time" + "CUSTOM_KEYS:{'validWhen':{'ref':'departure','value':true}}", example = "2020-01-31T12:45:00+01:00") @JsonProperty(value = "departure") protected ZonedDateTime departure; - @ApiModelProperty(value = "Arrival date and time" + + @Schema(description = "Arrival date and time" + "CUSTOM_KEYS:{'validWhen':{'ref':'arrival','value':true}}", example = "2020-01-31T13:15:00+01:00") @JsonProperty(value = "arrival") protected ZonedDateTime arrival; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteElement.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteElement.java index b30c669fc7..c99f895953 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteElement.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteElement.java @@ -15,11 +15,11 @@ package org.heigit.ors.api.responses.routing.gpx; -import org.locationtech.jts.geom.Coordinate; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RouteResult; import org.heigit.ors.routing.RouteSegment; import org.heigit.ors.routing.RouteStep; -import io.swagger.annotations.ApiModel; +import org.locationtech.jts.geom.Coordinate; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -27,7 +27,7 @@ import java.util.List; @XmlRootElement(name = "rte") -@ApiModel(value = "rte") +@Schema(name = "rte") public class GPXRouteElement { @XmlElement(name = "rtept") List routePoints; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteResponse.java index f3b355e327..286e7cc4b3 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/gpx/GPXRouteResponse.java @@ -15,11 +15,11 @@ package org.heigit.ors.api.responses.routing.gpx; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.api.responses.routing.RouteResponse; import org.heigit.ors.exceptions.StatusCodeException; import org.heigit.ors.routing.RouteResult; -import io.swagger.annotations.ApiModel; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -29,7 +29,7 @@ @XmlRootElement(name = "gpx") -@ApiModel(value = "gpx") +@Schema(name = "gpx") public class GPXRouteResponse extends RouteResponse { @XmlAttribute(name = "version") diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtra.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtra.java index a60995e508..2d4201c6fc 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtra.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtra.java @@ -16,15 +16,14 @@ package org.heigit.ors.api.responses.routing.json; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.ExtraSummaryItem; import org.heigit.ors.routing.RouteSegmentItem; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; -@ApiModel(value = "JSONExtra", description = "An object representing one of the extra info items requested") +@Schema(name = "JSONExtra", description = "An object representing one of the extra info items requested") public class JSONExtra { private final List> values; private final List summary; @@ -46,7 +45,7 @@ public JSONExtra(List segments, List summary } } - @ApiModelProperty(value = "A list of values representing a section of the route. The individual values are: \n" + + @Schema(description = "A list of values representing a section of the route. The individual values are: \n" + "Value 1: Indice of the staring point of the geometry for this section,\n" + "Value 2: Indice of the end point of the geoemetry for this sections,\n" + "Value 3: [Value](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html) assigned to this section.", @@ -56,7 +55,7 @@ private List> getValues() { return values; } - @ApiModelProperty(value = "List representing the summary of the extra info items.") + @Schema(description = "List representing the summary of the extra info items.") @JsonProperty("summary") private List getSummary() { return summary; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtraSummary.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtraSummary.java index 634ae6cbe9..356612a56d 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtraSummary.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONExtraSummary.java @@ -16,7 +16,8 @@ package org.heigit.ors.api.responses.routing.json; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; + public class JSONExtraSummary { private final double value; @@ -29,19 +30,19 @@ public JSONExtraSummary(double value, double distance, double amount) { this.amount = amount; } - @ApiModelProperty(value = "[Value](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html) of a info category.", example = "5") + @Schema(description = "[Value](https://GIScience.github.io/openrouteservice/documentation/extra-info/Extra-Info.html) of a info category.", example = "5") @JsonProperty("value") public double getValue() { return value; } - @ApiModelProperty(value = "Cumulative distance of this value.", example = "123.1") + @Schema(description = "Cumulative distance of this value.", example = "123.1") @JsonProperty("distance") public double getDistance() { return distance; } - @ApiModelProperty(value = "Category percentage of the entire route.", example = "23.8") + @Schema(description = "Category percentage of the entire route.", example = "23.8") @JsonProperty("amount") public double getAmount() { return amount; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONIndividualRouteResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONIndividualRouteResponse.java index ac896f01cf..da9aa21781 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONIndividualRouteResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONIndividualRouteResponse.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonUnwrapped; -import org.locationtech.jts.geom.Coordinate; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.api.responses.common.boundingbox.BoundingBoxFactory; import org.heigit.ors.common.DistanceUnit; @@ -28,8 +28,7 @@ import org.heigit.ors.routing.RouteWarning; import org.heigit.ors.util.DistanceUnitUtil; import org.heigit.ors.util.PolylineEncoder; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import org.locationtech.jts.geom.Coordinate; import java.time.ZonedDateTime; import java.util.ArrayList; @@ -38,38 +37,38 @@ import java.util.Map; @JsonInclude(JsonInclude.Include.NON_DEFAULT) -@ApiModel(value = "JSONIndividualRouteResponse", description = "An individual JSON based route created by the service") +@Schema(name = "JSONIndividualRouteResponse", description = "An individual JSON based route created by the service") public class JSONIndividualRouteResponse extends JSONBasedIndividualRouteResponse { - @ApiModelProperty(value = "The geometry of the route. For JSON route responses this is an encoded polyline.", example = "yuqlH{i~s@gaUe@VgEQFcBRbB_C") + @Schema(description = "The geometry of the route. For JSON route responses this is an encoded polyline.", example = "yuqlH{i~s@gaUe@VgEQFcBRbB_C") @JsonProperty("geometry") @JsonUnwrapped private final String geomResponse; - @ApiModelProperty("Summary information about the route") + @Schema(description = "Summary information about the route") private final JSONSummary summary; - @ApiModelProperty("List containing the segments and its corresponding steps which make up the route.") + @Schema(description = "List containing the segments and its corresponding steps which make up the route.") private final List segments; @JsonProperty("way_points") - @ApiModelProperty(value = "List containing the indices of way points corresponding to the *geometry*.", example = "[0,23]") + @Schema(description = "List containing the indices of way points corresponding to the *geometry*.", example = "[0,23]") private final List wayPoints; @JsonProperty("warnings") - @ApiModelProperty("List of warnings that have been generated for the route") + @Schema(description = "List of warnings that have been generated for the route") private List warnings; - @ApiModelProperty("List containing the legs the route consists of.") + @Schema(description = "List containing the legs the route consists of.") @JsonProperty("legs") @JsonInclude() private final List legs; private final Map extras; - @ApiModelProperty(value = "Departure date and time" + + @Schema(description = "Departure date and time" + "CUSTOM_KEYS:{'validWhen':{'ref':'departure','value':true}}", example = "2020-01-31T12:45:00+01:00") @JsonProperty(value = "departure") protected ZonedDateTime departure; - @ApiModelProperty(value = "Arrival date and time" + + @Schema(description = "Arrival date and time" + "CUSTOM_KEYS:{'validWhen':{'ref':'arrival','value':true}}", example = "2020-01-31T13:15:00+01:00") @JsonProperty(value = "arrival") protected ZonedDateTime arrival; @@ -129,7 +128,7 @@ private String constructEncodedGeometry(final Coordinate[] coordinates) { return ""; } - @ApiModelProperty(value = "A bounding box which contains the entire route", example = "[49.414057, 8.680894, 49.420514, 8.690123]") + @Schema(description = "A bounding box which contains the entire route", example = "[49.414057, 8.680894, 49.420514, 8.690123]") @JsonProperty("bbox") public double[] getBbox() { return bbox.getAsArray(); @@ -139,7 +138,7 @@ public String getGeomResponse() { return geomResponse; } - @ApiModelProperty(value = "List of extra info objects representing the extra info items that were requested for the route.") + @Schema(description = "List of extra info objects representing the extra info items that were requested for the route.") @JsonProperty("extras") public Map getExtras() { return extras; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONLeg.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONLeg.java index e63c26592c..05846136a9 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONLeg.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONLeg.java @@ -20,8 +20,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonUnwrapped; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RouteLeg; import org.heigit.ors.routing.RoutePtStop; import org.heigit.ors.routing.RouteStep; @@ -32,65 +31,65 @@ import java.util.ArrayList; import java.util.List; -@ApiModel(value="JSONLeg", description = "Leg of a route") +@Schema(name="JSONLeg", description = "Leg of a route") @JsonInclude(JsonInclude.Include.NON_EMPTY) public class JSONLeg { - @ApiModelProperty(value = "The type of the leg, possible values are currently 'walk' and 'pt'.", example = "pt") + @Schema(description = "The type of the leg, possible values are currently 'walk' and 'pt'.", example = "pt") @JsonProperty("type") private final String type; - @ApiModelProperty(value = "The departure location of the leg.", example = "Dossenheim, Süd Bstg G1") + @Schema(description = "The departure location of the leg.", example = "Dossenheim, Süd Bstg G1") @JsonProperty("departure_location") private final String departureLocation; - @ApiModelProperty(value = "The headsign of the public transport vehicle of the leg.", example = "Bismarckplatz - Speyererhof - EMBL - Boxberg - Mombertplatz") + @Schema(description = "The headsign of the public transport vehicle of the leg.", example = "Bismarckplatz - Speyererhof - EMBL - Boxberg - Mombertplatz") @JsonProperty("trip_headsign") private final String tripHeadsign; - @ApiModelProperty(value = "The public transport route name of the leg.", example = "RNV Bus 39A") + @Schema(description = "The public transport route name of the leg.", example = "RNV Bus 39A") @JsonProperty("route_long_name") private final String routeLongName; - @ApiModelProperty(value = "The public transport route name (short version) of the leg.", example = "39A") + @Schema(description = "The public transport route name (short version) of the leg.", example = "39A") @JsonProperty("route_short_name") private final String routeShortName; - @ApiModelProperty(value = "The route description of the leg (if provided in the GTFS data set).", example = "Bus") + @Schema(description = "The route description of the leg (if provided in the GTFS data set).", example = "Bus") @JsonProperty("route_desc") private final String routeDesc; - @ApiModelProperty(value = "The route type of the leg (if provided in the GTFS data set).", example = "1") + @Schema(description = "The route type of the leg (if provided in the GTFS data set).", example = "1") @JsonProperty("route_type") private final int routeType; - @ApiModelProperty(value = "The distance for the leg in metres.", example = "245") + @Schema(description = "The distance for the leg in metres.", example = "245") @JsonProperty("distance") private final Double distance; - @ApiModelProperty(value = "The duration for the leg in seconds.", example = "96.2") + @Schema(description = "The duration for the leg in seconds.", example = "96.2") @JsonProperty("duration") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.1d") private final Double duration; - @ApiModelProperty(value = "Departure date and time" + + @Schema(description = "Departure date and time" + "CUSTOM_KEYS:{'validWhen':{'ref':'departure','value':true}}", example = "2020-01-31T12:45:00+01:00") @JsonProperty(value = "departure") protected ZonedDateTime departure; - @ApiModelProperty(value = "Arrival date and time" + + @Schema(description = "Arrival date and time" + "CUSTOM_KEYS:{'validWhen':{'ref':'arrival','value':true}}", example = "2020-01-31T13:15:00+01:00") @JsonProperty(value = "arrival") protected ZonedDateTime arrival; - @ApiModelProperty(value = "The feed ID this public transport leg based its information from.", example = "gtfs_0") + @Schema(description = "The feed ID this public transport leg based its information from.", example = "gtfs_0") @JsonProperty("feed_id") private String feedId; - @ApiModelProperty(value = "The trip ID of this public transport leg.", example = "trip_id: vrn-19-39A-1-2-21-H-8-Special-50-42") + @Schema(description = "The trip ID of this public transport leg.", example = "trip_id: vrn-19-39A-1-2-21-H-8-Special-50-42") @JsonProperty("trip_id") private String tripId; - @ApiModelProperty(value = "The route ID of this public transport leg.", example = "vrn-19-39A-1") + @Schema(description = "The route ID of this public transport leg.", example = "vrn-19-39A-1") @JsonProperty("route_id") private String routeId; - @ApiModelProperty(value = "Whether the legs continues in the same vehicle as the previous one.", example = "false") + @Schema(description = "Whether the legs continues in the same vehicle as the previous one.", example = "false") @JsonProperty("is_in_same_vehicle_as_previous") private Boolean isInSameVehicleAsPrevious; - @ApiModelProperty(value = "The geometry of the leg. This is an encoded polyline.", example = "yuqlH{i~s@gaUe@VgEQFcBRbB_C") + @Schema(description = "The geometry of the leg. This is an encoded polyline.", example = "yuqlH{i~s@gaUe@VgEQFcBRbB_C") @JsonProperty("geometry") @JsonUnwrapped private final String geomResponse; - @ApiModelProperty("List containing the specific steps the segment consists of.") + @Schema(description = "List containing the specific steps the segment consists of.") @JsonProperty("instructions") private final List instructions; - @ApiModelProperty("List containing the stops the along the leg.") + @Schema(description = "List containing the stops the along the leg.") @JsonProperty("stops") private final List stops; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONPtStop.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONPtStop.java index 272c26f583..c296764da8 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONPtStop.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONPtStop.java @@ -18,47 +18,46 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RoutePtStop; import java.util.Date; import java.util.List; -@ApiModel(value="JSONPtStop", description = "Stop of a public transport leg") +@Schema(name="JSONPtStop", description = "Stop of a public transport leg") @JsonInclude(JsonInclude.Include.NON_EMPTY) public class JSONPtStop { - @ApiModelProperty(value = "The ID of the stop.", example = "de:08221:1138:0:O") + @Schema(description = "The ID of the stop.", example = "de:08221:1138:0:O") @JsonProperty("stop_id") private final String stopId; - @ApiModelProperty(value = "The name of the stop.", example = "Heidelberg, Alois-Link-Platz") + @Schema(description = "The name of the stop.", example = "Heidelberg, Alois-Link-Platz") @JsonProperty("name") private String name; - @ApiModelProperty(value = "The location of the stop.", example = "[8.6912542, 49.399979]") + @Schema(description = "The location of the stop.", example = "[8.6912542, 49.399979]") @JsonProperty("location") private List location; - @ApiModelProperty(value = "Arrival time of the stop.", example = "2022-07-04T13:22:00Z") + @Schema(description = "Arrival time of the stop.", example = "2022-07-04T13:22:00Z") @JsonProperty("arrival_time") private Date arrivalTime; - @ApiModelProperty(value = "Planned arrival time of the stop.", example = "2022-07-04T13:22:00Z") + @Schema(description = "Planned arrival time of the stop.", example = "2022-07-04T13:22:00Z") @JsonProperty("planned_arrival_time") private Date plannedArrivalTime; - @ApiModelProperty(value = "Predicted arrival time of the stop.", example = "2022-07-04T13:22:00Z") + @Schema(description = "Predicted arrival time of the stop.", example = "2022-07-04T13:22:00Z") @JsonProperty("predicted_arrival_time") private Date predictedArrivalTime; - @ApiModelProperty(value = "Whether arrival at the stop was cancelled.", example = "false") + @Schema(description = "Whether arrival at the stop was cancelled.", example = "false") @JsonProperty("arrival_cancelled") private Boolean arrivalCancelled; - @ApiModelProperty(value = "Departure time of the stop.", example = "2022-07-04T13:22:00Z") + @Schema(description = "Departure time of the stop.", example = "2022-07-04T13:22:00Z") @JsonProperty("departure_time") private Date departureTime; - @ApiModelProperty(value = "Planned departure time of the stop.", example = "2022-07-04T13:22:00Z") + @Schema(description = "Planned departure time of the stop.", example = "2022-07-04T13:22:00Z") @JsonProperty("planned_departure_time") private Date plannedDepartureTime; - @ApiModelProperty(value = "Predicted departure time of the stop.", example = "2022-07-04T13:22:00Z") + @Schema(description = "Predicted departure time of the stop.", example = "2022-07-04T13:22:00Z") @JsonProperty("predicted_departure_time") private Date predictedDepartureTime; - @ApiModelProperty(value = "Whether departure at the stop was cancelled.", example = "false") + @Schema(description = "Whether departure at the stop was cancelled.", example = "false") @JsonProperty("departure_cancelled") private Boolean departureCancelled; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONRouteResponse.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONRouteResponse.java index 1650821deb..71f093f080 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONRouteResponse.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONRouteResponse.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.graphhopper.util.shapes.BBox; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.api.responses.common.boundingbox.BoundingBoxFactory; import org.heigit.ors.api.responses.routing.IndividualRouteResponse; @@ -26,13 +27,11 @@ import org.heigit.ors.exceptions.StatusCodeException; import org.heigit.ors.routing.RouteResult; import org.heigit.ors.util.GeomUtility; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; -@ApiModel(value = "JSONRouteResponse") +@Schema(name = "JSONRouteResponse") public class JSONRouteResponse extends RouteResponse { public JSONRouteResponse(RouteResult[] routeResults, RouteRequest request) throws StatusCodeException { super(request); @@ -51,20 +50,20 @@ public JSONRouteResponse(RouteResult[] routeResults, RouteRequest request) throw } @JsonProperty("routes") - @ApiModelProperty(value = "A list of routes returned from the request") + @Schema(description = "A list of routes returned from the request") public JSONIndividualRouteResponse[] getRoutes() { return (JSONIndividualRouteResponse[]) routeResults.toArray(new JSONIndividualRouteResponse[routeResults.size()]); } @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_EMPTY) - @ApiModelProperty(value = "Bounding box that covers all returned routes", example = "[49.414057, 8.680894, 49.420514, 8.690123]") + @Schema(description = "Bounding box that covers all returned routes", example = "[49.414057, 8.680894, 49.420514, 8.690123]") public double[] getBBoxsArray() { return bbox.getAsArray(); } @JsonProperty("metadata") - @ApiModelProperty("Information about the service and request") + @Schema(description = "Information about the service and request") public RouteResponseInfo getInfo() { return responseInformation; } diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSegment.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSegment.java index 3516bc5e85..3dcbb2d788 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSegment.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSegment.java @@ -17,45 +17,44 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.api.requests.common.APIEnums; import org.heigit.ors.api.requests.routing.RouteRequest; import org.heigit.ors.routing.RouteSegment; import org.heigit.ors.routing.RouteStep; import org.heigit.ors.util.FormatUtility; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; -@ApiModel(description = "List containing the segments and its correspoding steps which make up the route.") +@Schema(description = "List containing the segments and its correspoding steps which make up the route.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class JSONSegment { - @ApiModelProperty(value = "Contains the distance of the segment in specified units.", example = "253") + @Schema(description = "Contains the distance of the segment in specified units.", example = "253") @JsonProperty("distance") @JsonInclude() private final Double distance; - @ApiModelProperty(value = "Contains the duration of the segment in seconds.", example = "37.7") + @Schema(description = "Contains the duration of the segment in seconds.", example = "37.7") @JsonProperty("duration") @JsonInclude() private final Double duration; - @ApiModelProperty("List containing the specific steps the segment consists of.") + @Schema(description = "List containing the specific steps the segment consists of.") @JsonProperty("steps") @JsonInclude() private final List steps; - @ApiModelProperty(value = "Contains the deviation compared to a straight line that would have the factor `1`. Double the Distance would be a `2`. CUSTOM_KEYS:{'validWhen':{'ref':'attributes','valueContains':'detourfactor'}}", example = "0.5") + @Schema(description = "Contains the deviation compared to a straight line that would have the factor `1`. Double the Distance would be a `2`. CUSTOM_KEYS:{'validWhen':{'ref':'attributes','valueContains':'detourfactor'}}", example = "0.5") @JsonProperty("detourfactor") private Double detourFactor; - @ApiModelProperty(value = "Contains the proportion of the route in percent. CUSTOM_KEYS:{'validWhen':{'ref':'attributes','valueContains':'percentage'}}", example = "43.2") + @Schema(description = "Contains the proportion of the route in percent. CUSTOM_KEYS:{'validWhen':{'ref':'attributes','valueContains':'percentage'}}", example = "43.2") @JsonProperty("percentage") private Double percentage; - @ApiModelProperty(value = "Contains the average speed of this segment in km/h. CUSTOM_KEYS:{'validWhen':{'ref':'attributes','valueContains':'avgspeed'}}", example = "56.3") + @Schema(description = "Contains the average speed of this segment in km/h. CUSTOM_KEYS:{'validWhen':{'ref':'attributes','valueContains':'avgspeed'}}", example = "56.3") @JsonProperty("avgspeed") private Double averageSpeed; - @ApiModelProperty(value = " Contains ascent of this segment in metres. CUSTOM_KEYS:{'validWhen':{'ref':'elevation',value:true}}", example = "56.3") + @Schema(description = " Contains ascent of this segment in metres. CUSTOM_KEYS:{'validWhen':{'ref':'elevation',value:true}}", example = "56.3") @JsonProperty("ascent") private Double ascent; - @ApiModelProperty(value = "Contains descent of this segment in metres. CUSTOM_KEYS:{'validWhen':{'ref':'elevation',value:true}}", example = "45.2") + @Schema(description = "Contains descent of this segment in metres. CUSTOM_KEYS:{'validWhen':{'ref':'elevation',value:true}}", example = "45.2") @JsonProperty("descent") private Double descent; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStep.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStep.java index 3883072d8a..d603f20417 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStep.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStep.java @@ -19,42 +19,41 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RouteStep; import org.heigit.ors.util.StringUtility; import java.util.Arrays; -@ApiModel(value="JSONStep", description = "Step of a route segment") +@Schema(name="JSONStep", description = "Step of a route segment") @JsonInclude(JsonInclude.Include.NON_EMPTY) public class JSONStep { - @ApiModelProperty(value = "The distance for the step in metres.", example = "245") + @Schema(description = "The distance for the step in metres.", example = "245") @JsonProperty("distance") private final Double distance; - @ApiModelProperty(value = "The duration for the step in seconds.", example = "96.2") + @Schema(description = "The duration for the step in seconds.", example = "96.2") @JsonProperty("duration") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.1d") private final Double duration; - @ApiModelProperty(value = "The [instruction](https://GIScience.github.io/openrouteservice/documentation/Instruction-Types.html) action for symbolisation purposes.", example = "1") + @Schema(description = "The [instruction](https://GIScience.github.io/openrouteservice/documentation/Instruction-Types.html) action for symbolisation purposes.", example = "1") @JsonProperty("type") private final Integer type; - @ApiModelProperty(value = "The routing instruction text for the step.", example = "Turn right onto Berliner Straße") + @Schema(description = "The routing instruction text for the step.", example = "Turn right onto Berliner Straße") @JsonProperty("instruction") private final String instruction; - @ApiModelProperty(value = "The name of the next street.", example = "Berliner Straße") + @Schema(description = "The name of the next street.", example = "Berliner Straße") @JsonProperty("name") private String name; - @ApiModelProperty(value = "Only for roundabouts. Contains the number of the exit to take.", example = "2") + @Schema(description = "Only for roundabouts. Contains the number of the exit to take.", example = "2") @JsonProperty("exit_number") private Integer exitNumber; - @ApiModelProperty(value = "Contains the bearing of the entrance and all passed exits in a roundabout CUSTOM_KEYS:{'validWhen':{'ref':'roundabout_exits',value:true}}.", example = "[10,45,60]") + @Schema(description = "Contains the bearing of the entrance and all passed exits in a roundabout CUSTOM_KEYS:{'validWhen':{'ref':'roundabout_exits',value:true}}.", example = "[10,45,60]") @JsonProperty("exit_bearings") private int[] exitBearings; - @ApiModelProperty(value = "List containing the indices of the steps start- and endpoint corresponding to the *geometry*.", example = "[45,48]") + @Schema(description = "List containing the indices of the steps start- and endpoint corresponding to the *geometry*.", example = "[45,48]") @JsonProperty("way_points") private int[] waypoints; - @ApiModelProperty(value = "The maneuver to be performed CUSTOM_KEYS:{'validWhen':{'ref':'maneuvers',value:true}}") + @Schema(description = "The maneuver to be performed CUSTOM_KEYS:{'validWhen':{'ref':'maneuvers',value:true}}") @JsonProperty("maneuver") private JSONStepManeuver maneuver; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStepManeuver.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStepManeuver.java index 4260f25a9e..c7974b4954 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStepManeuver.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONStepManeuver.java @@ -17,26 +17,25 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.locationtech.jts.geom.Coordinate; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RouteStepManeuver; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import org.heigit.ors.util.FormatUtility; +import org.locationtech.jts.geom.Coordinate; -@ApiModel(description = "Maneuver object of the step") +@Schema(description = "Maneuver object of the step") @JsonInclude(JsonInclude.Include.NON_EMPTY) public class JSONStepManeuver { private static final int COORDINATE_PRECISION = 6; private static final int ELEVATION_DECIMAL_PLACES = 2; - @ApiModelProperty(value = "The coordinate of the point where a maneuver takes place.", example = "[8.678962,49.407819]") + @Schema(description = "The coordinate of the point where a maneuver takes place.", example = "[8.678962,49.407819]") @JsonProperty("location") private Double[] location; - @ApiModelProperty(value = "The azimuth angle (in degrees) of the direction right before the maneuver.", example = "24") + @Schema(description = "The azimuth angle (in degrees) of the direction right before the maneuver.", example = "24") @JsonProperty("bearing_before") private final Integer bearingBefore; - @ApiModelProperty(value = "The azimuth angle (in degrees) of the direction right after the maneuver.", example = "96") + @Schema(description = "The azimuth angle (in degrees) of the direction right after the maneuver.", example = "96") @JsonProperty("bearing_after") private final Integer bearingAfter; diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSummary.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSummary.java index c529804ba1..50205db37a 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSummary.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONSummary.java @@ -18,27 +18,27 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RouteResult; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -@ApiModel(description = "Contains total sums of duration, route distance and actual distance of the route.") + +@Schema(description = "Contains total sums of duration, route distance and actual distance of the route.") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class JSONSummary { - @ApiModelProperty(value = "Total route distance in specified units.", example = "12.6") + @Schema(description = "Total route distance in specified units.", example = "12.6") @JsonProperty(value = "distance") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.2d") protected Double distance; - @ApiModelProperty(value = "Total duration in seconds.", example = "604") + @Schema(description = "Total duration in seconds.", example = "604") @JsonProperty(value = "duration") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.1d") protected Double duration; - @ApiModelProperty(value = "Total ascent in meters." + + @Schema(description = "Total ascent in meters." + "CUSTOM_KEYS:{'validWhen':{'ref':'elevation','value':true}}", example = "166.3") @JsonProperty(value = "ascent") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.1d") protected Double ascent; - @ApiModelProperty(value = "Total descent in meters." + + @Schema(description = "Total descent in meters." + "CUSTOM_KEYS:{'validWhen':{'ref':'elevation','value':true}}", example = "201.3") @JsonProperty(value = "descent") @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern = "%.1d") diff --git a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONWarning.java b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONWarning.java index f05e45404a..c229cc881f 100644 --- a/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONWarning.java +++ b/openrouteservice/src/main/java/org/heigit/ors/api/responses/routing/json/JSONWarning.java @@ -16,17 +16,17 @@ package org.heigit.ors.api.responses.routing.json; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.heigit.ors.routing.RouteWarning; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -@ApiModel(description = "Informs about possible difficulties like access restrictions on the generated route. Generates a corresponding `extras` object with the affected segments.") + +@Schema(description = "Informs about possible difficulties like access restrictions on the generated route. Generates a corresponding `extras` object with the affected segments.") public class JSONWarning { - @ApiModelProperty(value = "Identification code for the warning", example = "1") + @Schema(description = "Identification code for the warning", example = "1") @JsonProperty private final Integer code; - @ApiModelProperty( value = "The message associated with the warning", example = "This route may go over restricted roads") + @Schema(description = "The message associated with the warning", example = "This route may go over restricted roads") @JsonProperty private final String message; diff --git a/openrouteservice/src/main/resources/application.properties b/openrouteservice/src/main/resources/application.properties index 2b9c26726e..a979177a35 100644 --- a/openrouteservice/src/main/resources/application.properties +++ b/openrouteservice/src/main/resources/application.properties @@ -1,7 +1,16 @@ # Workaround for failing springfox-swagger2. # springfox-swagger2 should be replaced by the maintained springdoc-openapi -spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER +#spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER # Keep the context-path at / else the war file run with tomcat will have the context-path of /ors/v2 as well. server.servlet.context-path=/ors +spring.mvc.servlet.path=/ server.port=8082 server.error.whitelabel.enabled=false +springdoc.swagger-ui.enabled = true +springdoc.swagger-ui.path = /swagger-ui.html +springdoc.swagger-ui.tryItOutEnabled = true +springdoc.swagger-ui.filter = false +springdoc.swagger-ui.syntaxHighlight.activated = true +#springdoc.packagesToScan=package1, package2 +#springdoc.pathsToMatch=/ors/v2, /v2 +springdoc.api-docs.path=/v2/api-docs \ No newline at end of file diff --git a/openrouteservice/src/test/java/org/heigit/ors/api/util/SwaggerTest.java b/openrouteservice/src/test/java/org/heigit/ors/api/util/SwaggerTest.java index 0008d61dc2..1db7131f33 100644 --- a/openrouteservice/src/test/java/org/heigit/ors/api/util/SwaggerTest.java +++ b/openrouteservice/src/test/java/org/heigit/ors/api/util/SwaggerTest.java @@ -1,20 +1,20 @@ -package org.heigit.ors.api.util; - -import org.heigit.ors.api.SwaggerConfig; -import org.junit.jupiter.api.Test; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - - -class SwaggerTest { - @Test - void testGetSwaggerDocs() { - SwaggerConfig swagger_config = new SwaggerConfig(); - Docket api = swagger_config.api(); - assertEquals(DocumentationType.SWAGGER_2, api.getDocumentationType()); - assertTrue(api.isEnabled()); - } -} +//package org.heigit.ors.api.util; +// +//import org.heigit.ors.api.OpenApiConfiguration; +//import org.junit.jupiter.api.Test; +//import springfox.documentation.spi.DocumentationType; +//import springfox.documentation.spring.web.plugins.Docket; +// +//import static org.junit.jupiter.api.Assertions.assertEquals; +//import static org.junit.jupiter.api.Assertions.assertTrue; +// +// +//class SwaggerTest { +// @Test +// void testGetSwaggerDocs() { +// SwaggerConfig swagger_config = new SwaggerConfig(); +// Docket api = swagger_config.api(); +// assertEquals(DocumentationType.SWAGGER_2, api.getDocumentationType()); +// assertTrue(api.isEnabled()); +// } +//}