swagger-api / swagger-api/swagger-client

feat: externalValue resolver

Open
#1,978 9 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

type: enhancement type: feature version: 3.x
Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

Content & configuration

https://editor.swagger.io/?url=https://gist.githubusercontent.com/mathis-m/262703ffd14ac670366e603d0143943f/raw/4d4d7f3f5a5ba27c9880344976d7297e600588ce/tm8jDkQ5Cq.txt
Swagger/OpenAPI definition:

openapi: 3.0.0
info:
 title: asd
 version: "123"
paths:
 /:
   post:
     parameters:
       - in: header
         name: limit
         schema:
           type: integer
           maximum: 50
         examples:
           max:
             summary: A sample limit value  # Optional description
             externalValue: 'https://gist.githubusercontent.com/mathis-m/ad32902aa510d7e69b4b8d3b02e284a6/raw/613955421088a491231b1c6c7766f0f95a5c5824/vNwATb2zAG.txt'
     requestBody:
       content:
         application/json:
           schema:
             {}
           examples:
             jsonObject:
               summary: A sample object
               externalValue: 'https://gist.githubusercontent.com/mathis-m/e97d480acd5e13455beeba37947d2d8b/raw/9e26dfeeb6e641a33dae4961196235bdb965b21b/z1xx2GHQEY.txt'
         image/png:
           schema:
             type: string
             format: binary
           examples:
             KittenImage:
               externalValue: "https://placekitten.com/200/300"
     responses:
       "200":
         description: OK!
         content:
           application/json:
             schema:
               {}
             examples:
               jsonObject:
                 summary: A sample object
                 externalValue: 'https://gist.githubusercontent.com/mathis-m/e97d480acd5e13455beeba37947d2d8b/raw/9e26dfeeb6e641a33dae4961196235bdb965b21b/z1xx2GHQEY.txt'
Is your feature request related to a problem?

I think #5433 at swagger-ui is only partially a swagger-ui issue!
I have tried to integrate externalValue examples (from params, requestBody, response) into the sample generation process.
I realized that this value is not resolved, I think swagger-js should resolve this just like it resolves refs.
Originally posted by @mathis-m in https://github.com/swagger-api/swagger-ui/issues/5433#issuecomment-797645483
.

Describe the solution you'd like

I think swagger-js should resolve this just like it resolves refs.

Describe alternatives you've considered

Else ways I will implement some resolver that will fetch the raw value hosted behind the externalValue url within swagger-ui

Additional context

#5433 at swagger-ui

I have started implementing this and will create a PR for this if it is appreciated in a few days.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.