Skip to content

Support of "x-examples" for "body" type parameters (like sagger-ui v2.x.x) #7116

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

Closed
Clem69B opened this issue Mar 24, 2021 · 1 comment
Closed

Comments

@Clem69B
Copy link

Clem69B commented Mar 24, 2021

Content & configuration

Swagger/OpenAPI definition:

swagger: '2.0'
[...]
   post:
     tags:
       - _(deprecated) Triggers and Actions - V0 (use Triggers and Actions - V1 instead
     summary: Create an ActionPolicy
     description: 'The field `id` must not be provided, it will be automatically generated by the service as an UUID.<br><br>Usage of this API will be reported in your access log under ''routing'' category.<br><br>Restricted to API keys with at least one of the following roles : DATA_PROCESSING_W.'
     operationId: createUsingPOST_1
     consumes:
       - application/json
     produces:
       - application/json
     parameters:
       - in: body
         name: actionPolicy
         description: ActionPolicy to add
         required: true
         schema:
           $ref: '#/definitions/ActionPolicyV0'
         x-examples:
           default: |-
             {
                 "name": "name-aea80c1d-5777-4e20-822c-5e6871f428e5",
                 "enabled": true,
                 "triggers": {
                     "eventRuleIds": ["64e97cd3-9f49-43d9-84cf-7c4a806e3189"]
                 },
                 "actions": {
                     "emails": [{
                     "to": ["[email protected]"],
                     "cc": ["[email protected]"],
                     "cci": ["[email protected]"],
                     "subjectTemplate": "State change for {{stateKey}}",
                     "contentTemplate": "{{stateKey}} change from state {{previousState}} to state {{newState}} at {{timestamp}}"
                     }],
                     "sms": [{
                         "destinationPhoneNumbers": ["+33601234567"],
                         "contentTemplate": "{{stateKey}} new state {{newState}} at {{timestamp}}"
                     }]
                 }
             }
     responses:
       '200':
         description: ActionPolicy created
         schema:
           $ref: '#/definitions/ActionPolicyV0'
     security:
       - X-API-KEY:
           - global
     deprecated: true
[...]

Is your feature request related to a problem?

We have recently moved from swagger-ui 2.X.X to swagger-ui 3.X.X
In swagger-ui 2.x.x, "x-examples" are interpreted :
image

In swagger-ui 3.x.x, "x-examples" are ignored :
image

Describe the solution you'd like

The same behaviour as swagger-ui 2.X.X would be perfect

Describe alternatives you've considered

We know that "x-examples" is a vendor extension, and not a part of the swagger V2 specification. In fact, nothing seems to exist for body request examples.
The migration to OpenAPI v3 will be a good answer, but requires much more work on our side (annotation migration, springfox to springdoc migration, etc.).

Thankyou for any response

@Clem69B Clem69B changed the title Support for "x-examples" for "body" type parameters (like sagger-ui v2.x.x) Support of "x-examples" for "body" type parameters (like sagger-ui v2.x.x) Mar 24, 2021
@hkosova
Copy link
Contributor

hkosova commented Mar 24, 2021

Duplicate of #3233.

@hkosova hkosova closed this as completed Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants