File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 11import { Api } from "../Api.js" ;
22import handleJson , { removeTrailingSlash } from "./handleJson.js" ;
33import type { OpenAPIV3 } from "openapi-types" ;
4+ import type { RequestInitExtended } from "./types" ;
45
56export interface ParsedOpenApi3Documentation {
67 api : Api ;
@@ -9,10 +10,16 @@ export interface ParsedOpenApi3Documentation {
910}
1011
1112export default function parseOpenApi3Documentation (
12- entrypointUrl : string
13+ entrypointUrl : string ,
14+ options : RequestInitExtended = { }
1315) : Promise < ParsedOpenApi3Documentation > {
1416 entrypointUrl = removeTrailingSlash ( entrypointUrl ) ;
15- return fetch ( entrypointUrl )
17+ let headers : HeadersInit | undefined =
18+ typeof options . headers === "function" ? options . headers ( ) : options . headers ;
19+ headers = new Headers ( headers ) ;
20+ headers . append ( "Accept" , "application/vnd.openapi+json" ) ;
21+
22+ return fetch ( entrypointUrl , { ...options , headers : headers } )
1623 . then ( ( res ) => Promise . all ( [ res , res . json ( ) ] ) )
1724 . then (
1825 ( [ res , response ] : [ res : Response , response : OpenAPIV3 . Document ] ) => {
Original file line number Diff line number Diff line change 1+ export interface RequestInitExtended extends Omit < RequestInit , "headers" > {
2+ headers ?: HeadersInit | ( ( ) => HeadersInit ) ;
3+ }
You can’t perform that action at this time.
0 commit comments