JSON in OpenAPI / Swagger: Bodies and Responses
JSON in OpenAPI/Swagger specs: defining request bodies, response schemas, $ref components, and generating client code from JSON schema definitions.
Published:
Tags: json, api, developer-tools
JSON in OpenAPI / Swagger: Request Bodies, Responses, and Examples OpenAPI is a JSON (or YAML) document that describes a JSON API. The schema objects inside it β request bodies, response shapes, component definitions β are JSON Schema, which means the same , , , and machinery you use for data validation also describes your API contract. Getting these right produces accurate documentation, working code generation, and runtime validation. OpenAPI Request/Response Schema Keywords | Keyword | Purpose | Example | |---------|---------|---------| | requestBody | Defines the shape of the request body | | | schema | JSON Schema for the body content | | | responses | Maps HTTP status codes to response schemas | | | $ref | References a reusable schema component | | | additionalProperties | Allows orβ¦
All articles · theproductguy.in