swagger-api / swagger-api/swagger-ui
Change the requests based on the selected URL template
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: Ubuntu 16.04
- Browser: Chrome
- Version: 78
- Method of installation: no
- Swagger-UI version: e.g. 3.24.3
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Swagger/OpenAPI definition:
---
openapi: "3.0.1"
info:
title: "new"
version: "1"
servers:
-
url: "/"
security:
-
default: []
paths:
/{path}:
get:
parameters:
-
name: "path"
in: "path"
required: true
style: "simple"
explode: false
schema:
type: "string"
responses:
200:
description: "OK"
security:
-
default: []
/abc:
put:
parameters:
-
name: "q"
in: "query"
required: true
schema:
type: "string"
responses:
200:
description: "OK"
security:
-
default: []
components:
securitySchemes:
default:
type: "oauth2"
flows:
implicit:
authorizationUrl: "https://test.com"
scopes: {}
How can we help?
I have a basic understanding of swagger requestInterceptors which can be used to customize the outgoing requests. In one of my use cases, I need to customize the outgoing request based on URL template selected from the swagger (not from the final URL). How can I identify that?
For example, using the above definition, a user can invoke below
GET /{path}withpath=person/123which becomesGET /person%2F123PUT /abcwithq=item/123which becomesPUT /abc?q=item%2F123
From the request interceptor, I need to detect the requests coming through GET /{path} only and URL decode GET /person%2F123 into GET /person/123 before the actual call.
In the request object passed to the requestInterceptor I could not find the required information:
requestInterceptor: (request) => {
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Swagger UI's requestInterceptor handling and the request object passed to it, then trace how the OpenAPI path templates become final request URLs. Verify the behavior against the supplied GET /{path} and PUT /abc examples; done means the interceptor can distinguish the selected URL template before changing the outgoing request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100