Help Center/ ServiceStage/ API Reference/ ServiceComb APIs/ Schema/ Modifying a Microservice Schema
Updated on 2024-12-16 GMT+08:00

Modifying a Microservice Schema

Function

Modify a microservice schema based on schema_id.

Restrictions

In versions earlier than 2.3.33, schema overwriting is not supported in production environment. In version 2.3.33 and later, the environment variable SCHEMA_EDITABLE can be used to support schema overwriting.

URI

PUT /v4/{project_id}/registry/microservices/{service_id}/schemas/{schema_id}

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

  • For a professional microservice engine, enter the tenant project ID. The value contains 1 to 64 characters. See Obtaining a Project ID. You can also enter the fixed value default.
  • For an exclusive microservice engine, enter the fixed value default.

service_id

Yes

String

Microservice ID, which must be unique. The value contains 1 to 64 characters. Regular expression: ^.*$. See Querying Information About All Microservices.

schema_id

Yes

String

Microservice schema ID, which must be unique. The value contains 1 to 160 characters. Regular expression: ^[a-zA-Z0-9]{1,160}$|^[a-zA-Z0-9][a-zA-Z0-9_-.]{0,158}[a-zA-Z0-9]$. See Querying All Schema Information About a Microservice.

Request

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

Authorization

No

String

This parameter is mandatory if security authentication is enabled for an exclusive microservice engine. Otherwise, this parameter is not required.

The token of an exclusive microservice engine with security authentication enabled is in the following format:

Authorization:Bearer {Token}

For details about how to obtain the token, see Obtaining the User Token of an Exclusive Microservice Engine.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

schema

Yes

String

Schema content.

summary

No

String

Schema summary.

Response

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Status code: 500

Table 5 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Example Request

Modify the content and summary of a schema with specified service_id and schema_id.

PUT https://{endpoint}/v4/{project_id}/registry/microservices/{service_id}/schemas/{schema_id}

{
  "schema": "---\nswagger: \"2.0\"\ninfo:\n  version: \"1.0.0\"\n  title: \"swagger definition for com.service.provider.controller.ProviderImpl\"\n  x-java-interface: \"cse.gen.springmvc.provider.provider.ProviderImplIntf\"\nbasePath:  \"/provider\"\nconsumes:\n- \"application/json\"\nproduces:\n- \"application/json\"\npaths:\n  /helloworld:\n    get:\n      operationId: \"helloworld\"\n      produces:\n      - \"application/json\"\n      parameters:\n      - name: \"name\"\n        in: \"query\"\n        required: true\n        type: \"string\"\n      responses:\n        200:\n          description: \"response of 200\"\n          schema:\n            type: \"string\"\n",
  "summary": "test"
}

Example Response

None

Status Code

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Code

See ServiceComb Error Codes.