Skip to content

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

@BreyndotEchse

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

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