Create Schema
POST
https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/schemas
This call creates a new schema.
Request body should contain a schema
object which should atleast have these properties with string
values:
type
: Allowed types are openapi3
, openapi2
, openapi1
, raml
and graphql
.
language
: Allowed languages are json
and yaml
for OpenAPI and RAML schema types. GraphQL schema type accepts only graphql
language.
schema
: Optional. If passed, must be the content of the schema as a string
.
Response contains a schema
object with all the details related to the created schema, namely, id
, language
, type
etc.
Requires API Key as X-Api-Key
request header or apikey
URL query parameter.
Body
PARAM
Key |
Datatype |
Required |
Description |
HEADERS
Key |
Datatype |
Required |
Description |
Content-Type
|
string |
|
|
RESPONSES
status OK
{
"schema": {
"id": "e3b3a0b7-34d5-4fc5-83e0-118bd9e8c822",
"language": "yaml",
"apiVersion": "ad810c39-df60-434e-a76f-a2192cd8d81f",
"type": "openapi3",
"createdBy": "5665",
"updatedBy": "5665",
"createdAt": "2021-05-22T13:17:07.000Z",
"updatedAt": "2021-05-22T13:17:07.000Z"
}
}
|
curl -X POST 'https://api.getpostman.com/apis/undefined/versions/undefined/schemas' -H 'Content-Type: application/json' -d '{"schema":{"language":"yaml","schema":"{\n \"openapi\": \"3.0.0\",\n \"info\": null,\n \"version\": \"v1.0\",\n \"title\": \"API\",\n \"servers\": [\n {\n \"url\": \"http://localhost:3000\"\n }\n ],\n \"paths\": {\n \"/user\": {\n \"get\": {\n \"summary\": \"Returns details about a particular user\",\n \"operationId\": \"listUser\",\n \"tags\": [\n \"user\"\n ],\n \"parameters\": [\n {\n \"name\": \"id\",\n \"in\": \"query\",\n \"description\": \"ID of the user\",\n \"required\": true,\n \"schema\": {\n \"type\": \"integer\",\n \"format\": \"int32\"\n }\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Details about a user by ID\",\n \"headers\": {\n \"x-next\": {\n \"description\": \"A link to the next page of responses\",\n \"schema\": {\n \"type\": \"string\"\n }\n }\n },\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"\\\\'#/components/schemas/User\\\\'\"\n }\n }\n }\n },\n \"default\": {\n \"description\": \"Unexpected error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"\\\\'#/components/schemas/Error\\\\'\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"components\": {\n \"schemas\": {\n \"User\": {\n \"type\": \"object\",\n \"required\": [\n \"id\",\n \"name\"\n ],\n \"properties\": {\n \"id\": {\n \"type\": \"integer\",\n \"format\": \"int64\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"tag\": {\n \"type\": \"string\"\n }\n }\n },\n \"Error\": {\n \"type\": \"object\",\n \"required\": [\n \"code\",\n \"message\"\n ],\n \"properties\": {\n \"code\": {\n \"type\": \"integer\",\n \"format\": \"int32\"\n },\n \"message\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n}","type":"openapi3"}}'