Skip to content

openapi 'definition'/'component' matching a json response body #999

@michaelboulton

Description

@michaelboulton

For example, you have your openapi spec:

paths:
  /users/{userId}:
    get:
      summary: Get a user by ID
      parameters: ...
      responses:
        "200":
          description: A single user.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/User"

components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string

Instead of specifying

request:
  url: http://example.com/users/123
response:
  json:
    id: 123
    name: !anystr

you could point to a component in an openapi schema and say that the response schema just has to match it. 'required' fields would be automatically replaced with a !anyint !anystr if possible to infer?

request:
  url: http://example.com/users/123
response:
  with_openapi:
    path: /path/to/schema.json
    schema: "#/components/schemas/User"
  json:
    id: 123

This would be more useful for massive responses

grpc already implicitly does this as it requires a certain type to reflect into (but doesn't check 'required' fields as they don't exist in proto3).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions