Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: support speakeasy example expansion directive #94

Open
TristanSpeakEasy opened this issue Jan 29, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@TristanSpeakEasy
Copy link

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.

@daveshanley daveshanley added the enhancement New feature or request label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants