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.
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 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.
View the service contract of an application
- Log on to the EDAS console.
- In the left-side navigation pane, choose .
- In the left-side navigation tree of Spring Cloud, click Service Query.
- In the top navigation bar, select the Namespaces of a service and click the service name.
- In the Metadata section of the Servive Detail panel, view the API information in the interface metadata of the service.
If you use Swagger annotations, the parsed results of the annotations are displayed in the Description column.
View the change records of a service contract
- Log on to the EDAS console.
- In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, set Namespaces.
- From the Cluster Type drop-down list, select Container Service or Serverless Kubernetes Cluster and click a specific application.
- In the left-side navigation tree of Application Overview, click Change List.
- On the Change List page, select Deploy Application from the Change Type drop-down list and click View in the Actions column.
- On the Change List Details page, click Click View Changes.In the Service Contract Changes panel, you can view the change records of the service contract. The change records include the following types: Add Methods, Delete Methods, and Modify Methods.