Document Properties
Kbid
2914L4
Last Modified
02-Dec-2022
Added to KB
19-Jul-2019
Public Access
Everyone
Status
Online
Doc Type
Guidelines
Product
ICM 7.10
Guide - 7.10.12.2 Migrating to OpenApi 3.0 and Swagger 2.X Annotations

Introduction

This document shows major differences between swagger-annotations 1.5.x and 2.x.

General


1.5.x2.x
GeneratedOpenApi 2.0OpenApi 3.0
AnnotationsAnnotations 1.5.XSwagger 2.X Annotations
Specification documentationBasic StructureBasic Structure
Maven Repositoryio.swagger:swagger-annotations

io.swagger.core.v3:swagger-annotations

Annotations for Models

1.5.x2.xNotes
@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)

Annotations for Operations

1.5.x2.xNotes

@Path("/testpath")
@Api("Some API")

public class SomeClass

@Path("/test")
@Tag(name="testpath", description="Some API")

public class SomeClass

@ApiOperation@OperationSee below for usage
@APIResponsesremovedSee below for usage
@APIResponse@ApiResponseSee below for usage; ApiResponse.responseCode is a String now (not int)
@ApiParam(value = "...", example = "...")@Parameter(description = "...", example = "...")


Examples for Operations

Example for an API Operation
@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();
}

Others

1.5.x2.xNotes
@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.producesremovedWas removed, now MediaTypes are specified per-resource (with @Consumes/@Produces)
@Api(hidden = true)@Hidden@Hidden works for models or operations
Disclaimer
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.
The Intershop Knowledge Portal uses only technically necessary cookies. We do not track visitors or have visitors tracked by 3rd parties. Please find further information on privacy in the Intershop Privacy Policy and Legal Notice.
Home
Knowledge Base
Product Releases
Log on to continue
This Knowledge Base document is reserved for registered customers.
Log on with your Intershop Entra ID to continue.
Write an email to supportadmin@intershop.de if you experience login issues,
or if you want to register as customer.