Forum Discussion

nate_ubiquisoft's avatar
nate_ubiquisoft
New Contributor
7 years ago

Possible bug in JSON generation when using reusable examples from components/examples

Per documentation at https://swagger.io/docs/specification/adding-examples/ I should be able to define examples of schema objects and use them in request/response bodies. When defining a request body...
  • nate_ubiquisoft's avatar
    nate_ubiquisoft
    7 years ago

    UPDATE:

    Response from Support (Thanks Wesley!):

    I received an update from the dev team regarding this issue.
    It seems to be working as expected, somewhat.
    There's a difference between 'example' and 'examples'. 'example' can contain a single example value and cannot reference an external example. The value of 'example' will be taken as-is, and that's the result in the current API definition.
    'examples' can contain multiple named examples, and these examples can have references.

    To solve the issue, you would either change the 'example' to 'examples' and leave the rest as-is, or remove the name of the example under the 'example' and inline the value instead of referencing.
    The issue as of now however is that we currently support rendering of 'example' but not plural 'examples'. So, you will notice that using examples does not return correctly either.

    Adding the use of 'examples' is currently being track by our team. Currently I would advise you to keep defining the examples directly.

    Once again I apologize for any inconvenience.


    Seems that defining them per request/response body is the only way to produce valid JSON for client consumption until examples support is implemented.