A service contract refers to the description of microservice interfaces based on the OpenAPI specification. Microservice systems operate and run based on service contracts. After you deploy an application, you do not need to introduce dependencies to the application. You can view API information such as microservice interfaces and paths by using service contracts. You can use an easy method to query services and use features, such as service tests.
Background information
A service contract includes the following three features:
- API query
You can view important API information of a service provider or consumer by using a service contract. The information includes the method, parameter list, and return type. If you choose a Spring Cloud service, you can view the information such as the request method, request path, and class name.
- Swagger annotation parsing
Swagger is the major contributor to the OpenAPI specification. Swagger is not the only tool that supports the OpenAPI specification. However, it is a basic standard tool that can be used to describe APIs.
Service contracts support Swagger annotation parsing. The parsing results are displayed on the service contract page in the Enterprise Distributed Application Service (EDAS) console.
- For Swagger 2.0, the values of annotations, such as @ApiOperation, @ApiParam, and @ApiImplicitParam, are parsed and displayed in the Description column.
- For OpenAPI 3.0, the values of annotations, such as @Operation and @Parameter, are parsed and displayed in the Description column.
- Prerequisites of service test
The service test feature tests a service interface or path based on the API information of the service. The API information is collected by using a service contract.