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 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

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservice Governance > Spring Cloud.
  3. In the left-side navigation tree of Spring Cloud, click Service Query.
  4. In the top navigation bar, select the Namespaces of a service and click the service name.
  5. 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.

    Service details - service contract

View the change records of a service contract

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, set Namespaces.
  3. From the Cluster Type drop-down list, select Container Service or Serverless Kubernetes Cluster and click a specific application.
  4. In the left-side navigation tree of Application Overview, click Change List.
  5. On the Change List page, select Deploy Application from the Change Type drop-down list and click View in the Actions column.
  6. 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.