jsona-openapi 0.3.0

A openapi dsl in jsona
Documentation
---
source: crates/jsona-openapi/tests/tests.rs
expression: output
---
{
  "openapi": "3.0.0",
  "info": {
    "version": "0.1.9",
    "title": "Sample Api"
  },
  "servers": [
    {
      "url": "http://localhost:3000"
    }
  ],
  "security": [
    {
      "jwt": []
    }
  ],
  "paths": {
    "/a/{b}/c/{d}": {
      "post": {
        "summary": "full spec",
        "operationId": "endpoint1",
        "parameters": [
          {
            "name": "b",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "d",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "X-App-Key",
            "in": "header",
            "description": "x header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "default content-type application/json",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "null": {
                    "type": "null"
                  },
                  "bool": {
                    "type": "boolean"
                  },
                  "integer": {
                    "type": "integer"
                  },
                  "float": {
                    "type": "number"
                  },
                  "array1": {
                    "description": "a simple array",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "object1": {
                    "$ref": "#/components/schemas/object1"
                  },
                  "objectarray": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "a": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "a"
                      ]
                    },
                    "maxItems": 3
                  },
                  "time": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "null",
                  "bool",
                  "float",
                  "array1",
                  "object1",
                  "objectarray",
                  "time"
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "success response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bool": {
                      "type": "boolean"
                    },
                    "integer": {
                      "type": "integer"
                    },
                    "float": {
                      "type": "number"
                    },
                    "array1": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "object1": {
                      "type": "object",
                      "properties": {
                        "a": {
                          "type": "integer"
                        },
                        "b": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "a",
                        "b"
                      ]
                    },
                    "object2": {
                      "$ref": "#/components/schemas/object1"
                    }
                  },
                  "required": [
                    "bool",
                    "integer",
                    "float",
                    "array1",
                    "object1",
                    "object2"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "code",
                    "message"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/endpoint2": {
      "get": {
        "summary": "no req and res",
        "operationId": "endpoint2",
        "responses": {
          "200": {
            "description": ""
          }
        }
      }
    },
    "/endpoint3": {
      "post": {
        "summary": "custom content-type",
        "operationId": "endpoint3",
        "requestBody": {
          "content": {
            "applicaton/xml": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "applicaton/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/endpoint4": {
      "get": {
        "summary": "custom response header",
        "operationId": "endpoint4",
        "responses": {
          "200": {
            "description": "",
            "headers": {
              "X-RateLimit": {
                "required": true,
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/endpoint6": {
      "get": {
        "summary": "operation x-*",
        "operationId": "endpoint5",
        "x-swagger-router-controller": "OrderController",
        "responses": {
          "200": {
            "description": ""
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "object1": {
        "type": "object",
        "properties": {
          "a": {
            "type": "integer"
          },
          "b": {
            "type": "integer"
          }
        },
        "required": [
          "a",
          "b"
        ]
      }
    },
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}