Create Schema - YAML

POST https://api.getpostman.com/apis/{{apiId}}/schemas

Create Schema - YAML

Creates a new schema for an API via YAML format.

Overview

Body tab

  • type — A string value that contains the schema's type. One of:
    • openapi3_1
    • openapi3
    • openapi2
    • openapi1
    • raml
    • raml1
    • wsdl1
    • wsdl2
    • graphql
    • proto2
    • graphql
    • proto3
  • files — An array that contains information for the YAML file to be created.

Sends the yamlSchemaFromRepo_stringified variable that houses the JSON of the schema that we need to build the API.

Pre-request Script tab

Sends a message to the Console that the Request is starting to create a new API schema.

Test tab

  1. Checks for a 404 HTTP response and if so, it gets the schema ID via an API call and saves it to a Collection Variable.
  2. If there's no 404 HTTP response, the Request just saves the schema ID to a Collection Variable and checks for a 201 HTTP response.

Request Body

{"type"=>"openapi:3", "files"=>[{"path"=>"demo_schema.json", "content"=>"{{jsonSchemaFromRepo_escaped}}"}]}

HEADERS

KeyDatatypeRequiredDescription
Content-Typestring
Acceptstring

RESPONSES

status: Created

{"id":"15d30826-a3b6-4ab4-8494-5508f8e35be5","type":"openapi:3","files":[{"id":"15d30826-a3b6-4ab4-8494-5508f8e35be5","name":"demo_schema.json","path":"demo_schema.json","updatedAt":"2023-04-19T14:01:07.000Z","createdAt":"2023-04-19T14:01:07.000Z","root":{"enabled":true},"createdBy":"24113298","updatedBy":"24113298"}],"updatedAt":"2023-04-19T14:01:07.000Z","createdAt":"2023-04-19T14:01:07.000Z","createdBy":"24113298","updatedBy":"24113298"}