~/json-yaml-converter

Convert an OpenAPI / Swagger spec between YAML and JSON

An OpenAPI 3.x spec converted between formats. Most editors prefer one; most tooling accepts both. Round-trip safe with YAML 1.2.

# context

OpenAPI specs exist in YAML for editor readability and in JSON for code generators that prefer it (anything built on swagger-codegen). The schemas are identical. Many teams keep the YAML as the source of truth and CI-generate the JSON for distribution.

# sample (JSON)

{
  "openapi": "3.1.0",
  "info": {
    "title": "Users API",
    "version": "1.0.0"
  },
  "paths": {
    "/users/{id}": {
      "get": {
        "summary": "Get a user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/User" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" }
        }
      }
    }
  }
}

→ Open in JSON ↔ YAML converter (pre-filled)

# notes

# other examples