ModernCalcs

Swagger/OpenAPI Generator

Build a list of endpoints and generate a valid OpenAPI 3.0 JSON specification, with schemas inferred from your example request bodies.

{
  "openapi": "3.0.3",
  "info": {
    "title": "My API",
    "version": "1.0.0"
  },
  "paths": {
    "/users": {
      "get": {
        "summary": "List users",
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      },
      "post": {
        "summary": "Create user",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Jane Doe"
                  },
                  "email": {
                    "type": "string",
                    "example": "jane@example.com"
                  }
                }
              },
              "example": {
                "name": "Jane Doe",
                "email": "jane@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "summary": "Get user by ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      }
    }
  }
}

Swagger/OpenAPI Generator: Skip the Hand-Written YAML

Writing an OpenAPI spec by hand means getting a deeply nested JSON/YAML structure exactly right — paths, operations, parameters, request body schemas. This tool lets you describe endpoints through a plain form (method, path, an example request body) and generates a real OpenAPI 3.0 document, inferring the request schema from your example JSON automatically.

Formula
endpoint {method, path, exampleBody} → OpenAPI operation {parameters (from {path} segments), requestBody (schema inferred from example), responses}

Schema inference walks your example JSON's structure recursively to build a matching OpenAPI schema object.

From Example JSON to Schema

Rather than making you write `{ type: "object", properties: { name: { type: "string" }, ... } }` by hand, this tool takes a real example request body and infers that structure automatically — an object's keys become schema properties, an array's item schema comes from its first element, and scalar values map to the appropriate OpenAPI type with the original value preserved as an example.

Automatic Path Parameter Detection

OpenAPI requires every `{param}` placeholder in a path to be explicitly declared as a parameter object — this tool scans your path string for that pattern and adds the required parameter declarations automatically, so `/users/{id}` correctly produces an `id` path parameter without extra configuration.

Practical Examples

Documenting a New Endpoint

Adding a POST /orders endpoint with a request body.

  • 1.Method: post, Path: /orders
  • 2.Paste an example order JSON as the body
  • 3.Schema is inferred automatically in the generated spec

What Gets Generated

  • openapi/info block with your title and version
  • paths object with one entry per endpoint
  • Path parameters inferred from {placeholders}
  • Request body schema inferred from example JSON

Good Use Cases

  • Bootstrapping an OpenAPI spec for a new API quickly
  • Documenting an existing API without hand-writing YAML
  • Generating a starting point to refine in a dedicated OpenAPI editor
  • Producing a spec to feed into client code generators

Frequently Asked Questions

How does schema inference work?

Pasting an example JSON request body walks its structure recursively, mapping each value to an OpenAPI schema type — objects become { type: "object", properties }, arrays infer their item schema from the first element, and scalars map to string/number/integer/boolean with the original value kept as an example.

How are path parameters detected?

Any {name} segment in your path (like /users/{id}) is automatically added as a required path parameter with a string schema — no separate parameter configuration needed.

Why does the output only have a 200 response by default?

This tool focuses on getting the request side (paths, methods, parameters, request bodies) right quickly — you'll typically want to add more detailed response schemas and additional status codes (400, 404, etc.) by hand afterward for a production-ready spec.

Is this valid OpenAPI 3.0 that tools like Swagger UI will accept?

Yes — the output follows the OpenAPI 3.0.3 structure (openapi/info/paths with proper operation objects), so it loads correctly in Swagger UI, Redoc, and OpenAPI-based code generators, though you should review and extend it for anything beyond the basic shape this tool produces.

Is my data sent anywhere?

No, the spec is generated entirely in your browser.