requestInterceptor that returns promise breaks curlify output
See original GitHub issueQ&A (please complete the following information)
- OS: Windows 10
- Browser: Chrome
- Version: 67.0.3396.99
- Method of installation: dist assets
- Swagger-UI version: 3.17.6
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.0
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: 'http://petstore.swagger.io/v1'
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
responses:
'200':
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
Swagger-UI configuration options:
SwaggerUI({
url: "https://api.myjson.com/bins/1h15yo",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl,
],
requestInterceptor: req => {
//return req;
return new Promise((resolve, reject) => resolve(req));
}
})
Describe the bug you’re encountering
When using a requestInterceptor
that returns a promise (that resolves to the request), instead of the pure request, the curl statement generated with curlify results in curl -X "undefined"
. Although the modified request is being used to send the http request.
To reproduce…
Steps to reproduce the behavior:
- See this jsfiddle: https://jsfiddle.net/falxfalx/6xy24zL9/32/
- Press play
- Try it out on GET /pets
- Execute
- Observe generated curl request
- Now comment requestInterceptor return statement and uncomment the
return req;
line - Repeat step 2 through 5 (this is expected behaviour)
Expected behavior
The displayed curl request should not be undefined.
Additional context or thoughts
Since I saw that curlify.js has a curl function that is to be called with the request as argument, I suspect that when returning a promise, the curlify call becomes: curl(promise)
while it should be something like:
const req = await promise;
curl(req);
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
swagger-ui-dist - UNPKG
node_modules/@babel/runtime-corejs2/core-js/promise.js","webpack://SwaggerUIBundle/. ... src/core/curlify.js","webpack://SwaggerUIBundle/.
Read more >share/swagger-ui.js.map - metacpan.org
node_modules/core-js/modules/_new-promise-capability.js","webpack://SwaggerUICore/. ... src/core/curlify.js","webpack://SwaggerUICore/.
Read more >swagger-static.swagger-ui-bundle.js.map Maven / Gradle / Ivy
swagger-static.swagger-ui-bundle.js.map maven / gradle build tool code. The class is part of the package ➦ Group: com.smoketurner ➦ Artifact: ...
Read more >swagger-ui: Versions - Openbase
ES Module output bundle path now points to swagger-ui-es-bundle-core , which ... requestInterceptor: use async/await to support return new Promise (#6279) ...
Read more >api/docs/swagger-ui-es-bundle-core.js.map - Fossies
node_modules/@babel/runtime-corejs3/core-js-stable/promise.js","webpack://SwaggerUIBundle/. ... src/core/curlify.js","webpack://SwaggerUIBundle/.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If the request url isn’t changed by requestInterceptor asynchronously this issue can be worked around like this:
Adding
showMutatedRequest: false
to the config seems to work for me. Without this option I’m seeing the same issue with the curl output.