FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix missing default "Accept" header if options.headers is falsy by BreyndotEchse · Pull Request #177 · api-platform/api-doc-parser · GitHub

Fix missing default "Accept" header if options.headers is falsy - #177

Open
BreyndotEchse wants to merge 1 commit into
api-platform:mainfrom
BreyndotEchse:bugfix/fetch-json-missing-accept-header
Open

Fix missing default "Accept" header if options.headers is falsy#177
BreyndotEchse wants to merge 1 commit into
api-platform:mainfrom
BreyndotEchse:bugfix/fetch-json-missing-accept-header

Conversation

Copy link
Copy Markdown
Q A
Branch main
License MIT

schemaAnalyzer.resolveSchemaParameters() calls schema.getParameters() without options argument (which defaults to {})
https://github.com/api-platform/admin/blob/ab9239cc0b750ad9339de0bc856031b0da47dc38/src/introspection/schemaAnalyzer.ts#L14:L16

From now on the empty options object gets passed getParameters() -> fetchResource() -> fetchJsonLd() -> setHeaders()

const { parameters = [] } = await fetchResource(resource.url, options);

https://github.com/api-platform/api-doc-parser/blob/1f6772b96936030ea4308efd04d0f69de5a24482/src/hydra/fetchResource.ts#L9:L13

const response = await fetch(url, setHeaders(options));

The first if in setHeaders() returns early without any headers, if options.headers is falsy - what is always the case when the options object is empty itself. So the default "Accept" header will not be set.

https://github.com/api-platform/api-doc-parser/blob/1f6772b96936030ea4308efd04d0f69de5a24482/src/hydra/fetchJsonLd.ts#L64:L66

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL