Full Article

Generating OpenAPI Swagger Documentation from Source Code, with GPT-4.1

Appendix

Simpler version of OpenAPI 3.0 in JSON Schema

{
  "name": "openapi3",
  "strict": false,
  "description": null,
  "schema": {
    "description": "The description of OpenAPI v3.0.x Documents",
    "type": "object",
    "required": [
      "openapi",
      "info",
      "paths"
    ],
    "properties": {
      "openapi": {
        "description": "@pattern ^3\\.0\\.\\d(-.+)?$",
        "type": "string"
      },
      "info": {
        "$ref": "#/$defs/Info"
      },
      "externalDocs": {
        "$ref": "#/$defs/ExternalDocumentatio2n"
      },
      "servers": {
        "type": "array",
        "items": {
          "$ref": "#/$defs/Server"
        }
      },
      "security": {
        "type": "array",
        "items": {
          "$ref": "#/$defs/SecurityRequirement"
        }
      },
      "tags": {
        "description": "@uniqueItems",
        "type": "array",
        "items": {
          "$ref": "#/$defs/Tag"
        }
      },
      "paths": {
        "$ref": "#/$defs/Paths"
      },
      "components": {
        "$ref": "#/$defs/Components"
      }
    }
  }
}