Skip to content

feature request: support speakeasy example expansion directive #94

@TristanSpeakEasy

Description

@TristanSpeakEasy

consider the below schemas:

  map:
    type: object
    additionalProperties:
      $ref: "#/components/schemas/simpleObject"
    example: { "key": "...", "key2": "..." }
  arr:
    type: array
    items:
      $ref: "#/components/schemas/simpleObject"
    example: ["...", "..."]

These use an example expansion directive of "..." (btw this is a special directive value speakeasy uses to direct our generator how to generate examples, we would be open to discussing alternative directives that both speakeasy and wiretap could use if you didn't want to support this one) which tells our generator to expand the example with an example value generated from the child schema, ie the additionalProperties schema or items schema.

In the examples above we are saying we want the map example to contain two keys (key and key2) where the values are using the example generated from the simpleObject component. This provides a shorthand to avoid having to define the whole json object in the example at this level and instead take advantage of the fact the examples have already been defined in the component.

The array version is just saying I want two values of the example defined in the simpleObject component.

Would love if the mocking from wiretap also supported this (or something similar that we can converge on) as it does reduce the burden for the example implementor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions