Skip to content

Latest commit

 

History

History
722 lines (707 loc) · 14.6 KB

openapi-v3.md

File metadata and controls

722 lines (707 loc) · 14.6 KB

OpenAPI 3.0

These schemas were automatically generated on 2021-06-14 using these Sequelize models and the most recent version of sequelize-to-json-schemas. To confirm that these are indeed all valid schemas use:

User Model

{
  "title": "Custom User Title",
  "description": "Custom User Description",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int32"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "ARRAY_INTEGERS": {
      "type": "array",
      "items": {
        "type": "integer",
        "format": "int32"
      }
    },
    "ARRAY_TEXTS": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "ARRAY_ALLOWNULL_EXPLICIT": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "nullable": true
    },
    "ARRAY_ALLOWNULL_IMPLICIT": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "nullable": true
    },
    "ARRAY_ENUM_STRINGS": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "hello",
          "world"
        ]
      }
    },
    "BLOB": {
      "type": "string",
      "format": "byte"
    },
    "CITEXT": {
      "type": "string"
    },
    "INTEGER": {
      "type": "integer",
      "format": "int32",
      "default": 0
    },
    "STRING": {
      "type": "string",
      "default": "Default value for STRING"
    },
    "STRING_ALLOWNULL_EXPLICIT": {
      "type": "string",
      "nullable": true
    },
    "STRING_ALLOWNULL_IMPLICIT": {
      "type": "string",
      "nullable": true
    },
    "STRING_1234": {
      "type": "string",
      "maxLength": 1234
    },
    "STRING_DOT_BINARY": {
      "type": "string",
      "format": "binary"
    },
    "TEXT": {
      "type": "string"
    },
    "UUIDV4": {
      "type": "string",
      "format": "uuid"
    },
    "JSON": {
      "anyOf": [
        {
          "type": "object"
        },
        {
          "type": "array"
        },
        {
          "type": "boolean"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        }
      ],
      "type": "object"
    },
    "JSONB_ALLOWNULL": {
      "anyOf": [
        {
          "type": "object"
        },
        {
          "type": "array"
        },
        {
          "type": "boolean"
        },
        {
          "type": "integer"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        }
      ],
      "nullable": true
    },
    "VIRTUAL": {
      "type": "boolean"
    },
    "VIRTUAL_DEPENDENCY": {
      "type": "integer",
      "format": "int32"
    },
    "CUSTOM_DESCRIPTION": {
      "type": "string",
      "description": "Custom attribute description"
    },
    "CUSTOM_COMMENT": {
      "type": "string"
    },
    "CUSTOM_EXAMPLES": {
      "type": "string",
      "example": [
        "Custom example 1",
        "Custom example 2"
      ]
    },
    "CUSTOM_READONLY": {
      "type": "string",
      "readOnly": true
    },
    "CUSTOM_WRITEONLY": {
      "type": "string",
      "writeOnly": true
    },
    "companyId": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    },
    "bossId": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    },
    "profile": {
      "$ref": "#/components/schemas/profile"
    },
    "company": {
      "$ref": "#/components/schemas/company"
    },
    "documents": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/document"
      }
    },
    "boss": {
      "$ref": "#/components/schemas/user"
    },
    "friends": {
      "type": "array",
      "items": {
        "allOf": [
          {
            "$ref": "#/components/schemas/user"
          },
          {
            "type": "object",
            "properties": {
              "friendships": {
                "$ref": "#/components/schemas/friendship"
              }
            }
          }
        ]
      }
    }
  },
  "required": [
    "id",
    "createdAt",
    "updatedAt",
    "ARRAY_INTEGERS",
    "ARRAY_TEXTS",
    "ARRAY_ENUM_STRINGS",
    "BLOB",
    "CITEXT",
    "INTEGER",
    "STRING",
    "STRING_1234",
    "STRING_DOT_BINARY",
    "TEXT",
    "UUIDV4",
    "JSON",
    "VIRTUAL",
    "VIRTUAL_DEPENDENCY",
    "CUSTOM_DESCRIPTION",
    "CUSTOM_COMMENT",
    "CUSTOM_EXAMPLES",
    "CUSTOM_READONLY",
    "CUSTOM_WRITEONLY"
  ]
}

Profile Model

{
  "title": "Profile",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int32"
    },
    "name": {
      "type": "string",
      "nullable": true
    },
    "userId": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    }
  },
  "required": [
    "id"
  ]
}

Document Model

{
  "title": "Document",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int32"
    },
    "name": {
      "type": "string",
      "nullable": true
    },
    "userId": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    }
  },
  "required": [
    "id"
  ]
}

Company Model

{
  "title": "Company",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int32"
    },
    "name": {
      "type": "string",
      "nullable": true
    }
  },
  "required": [
    "id"
  ]
}

Friendship Model

{
  "title": "Friendship",
  "type": "object",
  "properties": {
    "isBestFriend": {
      "type": "boolean",
      "nullable": true,
      "default": false
    },
    "userId": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    },
    "friendId": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    }
  },
  "required": [
    "isBestFriend"
  ]
}

Full Schema

Please note that sequelize-to-json-schemas does NOT generate full schemas. This is just an example of how to integrate the generated model schemas into a full OpenAPI 3.0 document (by adding model schemas to components.schemas).

{
  "openapi": "3.0.2",
  "info": {
    "title": "Fake API",
    "version": "0.0.1"
  },
  "paths": {
    "/users": {
      "get": {
        "parameters": [],
        "responses": {
          "404": {
            "description": "not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "user": {
        "title": "Custom User Title",
        "description": "Custom User Description",
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "ARRAY_INTEGERS": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            }
          },
          "ARRAY_TEXTS": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ARRAY_ALLOWNULL_EXPLICIT": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "ARRAY_ALLOWNULL_IMPLICIT": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "ARRAY_ENUM_STRINGS": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "hello",
                "world"
              ]
            }
          },
          "BLOB": {
            "type": "string",
            "format": "byte"
          },
          "CITEXT": {
            "type": "string"
          },
          "INTEGER": {
            "type": "integer",
            "format": "int32",
            "default": 0
          },
          "STRING": {
            "type": "string",
            "default": "Default value for STRING"
          },
          "STRING_ALLOWNULL_EXPLICIT": {
            "type": "string",
            "nullable": true
          },
          "STRING_ALLOWNULL_IMPLICIT": {
            "type": "string",
            "nullable": true
          },
          "STRING_1234": {
            "type": "string",
            "maxLength": 1234
          },
          "STRING_DOT_BINARY": {
            "type": "string",
            "format": "binary"
          },
          "TEXT": {
            "type": "string"
          },
          "UUIDV4": {
            "type": "string",
            "format": "uuid"
          },
          "JSON": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "array"
              },
              {
                "type": "boolean"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "type": "object"
          },
          "JSONB_ALLOWNULL": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "array"
              },
              {
                "type": "boolean"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "nullable": true
          },
          "VIRTUAL": {
            "type": "boolean"
          },
          "VIRTUAL_DEPENDENCY": {
            "type": "integer",
            "format": "int32"
          },
          "CUSTOM_DESCRIPTION": {
            "type": "string",
            "description": "Custom attribute description"
          },
          "CUSTOM_COMMENT": {
            "type": "string"
          },
          "CUSTOM_EXAMPLES": {
            "type": "string",
            "example": [
              "Custom example 1",
              "Custom example 2"
            ]
          },
          "CUSTOM_READONLY": {
            "type": "string",
            "readOnly": true
          },
          "CUSTOM_WRITEONLY": {
            "type": "string",
            "writeOnly": true
          },
          "companyId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "bossId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "profile": {
            "$ref": "#/components/schemas/profile"
          },
          "company": {
            "$ref": "#/components/schemas/company"
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/document"
            }
          },
          "boss": {
            "$ref": "#/components/schemas/user"
          },
          "friends": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/user"
                },
                {
                  "type": "object",
                  "properties": {
                    "friendships": {
                      "$ref": "#/components/schemas/friendship"
                    }
                  }
                }
              ]
            }
          }
        },
        "required": [
          "id",
          "createdAt",
          "updatedAt",
          "ARRAY_INTEGERS",
          "ARRAY_TEXTS",
          "ARRAY_ENUM_STRINGS",
          "BLOB",
          "CITEXT",
          "INTEGER",
          "STRING",
          "STRING_1234",
          "STRING_DOT_BINARY",
          "TEXT",
          "UUIDV4",
          "JSON",
          "VIRTUAL",
          "VIRTUAL_DEPENDENCY",
          "CUSTOM_DESCRIPTION",
          "CUSTOM_COMMENT",
          "CUSTOM_EXAMPLES",
          "CUSTOM_READONLY",
          "CUSTOM_WRITEONLY"
        ]
      },
      "profile": {
        "title": "Profile",
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "document": {
        "title": "Document",
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "company": {
        "title": "Company",
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id"
        ]
      },
      "friendship": {
        "title": "Friendship",
        "type": "object",
        "properties": {
          "isBestFriend": {
            "type": "boolean",
            "nullable": true,
            "default": false
          },
          "userId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "friendId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "required": [
          "isBestFriend"
        ]
      }
    }
  }
}