This document shows major differences between swagger-annotations 1.5.x and 2.x.
1.5.x | 2.x | |
---|---|---|
Generated | OpenApi 2.0 | OpenApi 3.0 |
Annotations | Annotations 1.5.X | Swagger 2.X Annotations |
Specification documentation | Basic Structure | Basic Structure |
Maven Repository | io.swagger:swagger-annotations | io.swagger.core.v3:swagger-annotations |
1.5.x | 2.x | Notes |
---|---|---|
@APIModel(description = "...") | @Schema(description = "...") | @Schema is used not only to define schemas (which are basically entities/data classes or properties) but also to reference such with @Schema(implementation=<someclass>.class) |
@APIModelProperty(description = "...") | @Schema(description = "...") | Only if the decorated getter is not an array type. |
@APIModelProperty(description = "...") | @ArraySchema(schema = @Schema(implementation = <someclass>.class, description = "...")) | Only if the decorated getter is an array type. |
@APIModelProperty(readOnly = true) | @Schema(accessMode=AccessMode.READ_ONLY) |
1.5.x | 2.x | Notes |
---|---|---|
@Path("/testpath") | @Path("/test") | |
@ApiOperation | @Operation | See below for usage |
@APIResponses | removed | See below for usage |
@APIResponse | @ApiResponse | See below for usage; ApiResponse.responseCode is a String now (not int) |
@ApiParam(value = "...", example = "...") | @Parameter(description = "...", example = "...") |
@Operation(summary = "Gets the recurring order with the given identifier", responses = { @ApiResponse(responseCode = OK, description = OK_MSG, content = @Content(schema = @Schema(implementation = RecurringOrderRO.class))), @ApiResponse(responseCode = NOT_FOUND, description = NOT_FOUND_MSG) }) @GET @Path("/{externalID}/") @Override public Response get(@Parameter(description = "The external id") @PathParam("externalID") String externalID) { return Response.ok(something).build(); }
1.5.x | 2.x | Notes |
---|---|---|
@SwaggerDefinition(basePath = "/myapi", host="intershop.de" info = @Info(...), consumes = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }, produces = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }, schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS }) | @OpenAPIDefinition( servers= { @Server(url="http://intershop.de/myapi"), @Server(url="https://intershop.de/myapi") }, info = @Info(...)) | basePath, host and schemes are now merged into servers |
@SwaggerDefinition.consumes, @SwaggerDefinition.produces | removed | Was removed, now MediaTypes are specified per-resource (with @Consumes/@Produces) |
@Api(hidden = true) | @Hidden | @Hidden works for models or operations |
The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.