OpenAPI Specification Schemas: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 1: Line 1:
=External=
=External=
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject
* https://tools.ietf.org/html/draft-bhutton-json-schema-00
* https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00
=Internal=
=Internal=
* [[OpenAPI_Specification#schemas|OpenAPI Specification]]
* [[OpenAPI_Specification#schemas|OpenAPI Specification]]

Revision as of 01:41, 26 January 2024

External

Internal

Overview

The /components/schemas section of the OpenAPI specification defines reusable types that are used as input and output data types. These types can represent objects, but also primitives and arrays. A client or server code generator creates programming language types from these schemas. This article is annotated with details related to how oapi-codegen generates Go code.

Example

components:
  schemas:
    Pet:
      allOf:
        - $ref: '#/components/schemas/NewPet'
        - type: object
          required:
            - id
          properties:
            id:
              type: integer
              format: int64
    NewPet:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        tag:
          type: string
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string

Schema Name