Skip to content

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

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

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

@soyuka

soyuka commented Sep 26, 2026

Copy link
Copy Markdown
Member

thanks!

@soyuka soyuka closed this Sep 26, 2026
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.

2 participants