forked from ferdikoomen/openapi-typescript-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By default this library adds a `Accept: application/json` header to requests. We want to signal that other content types are accepted also, eg 'application/pdf'. Furthermore, Axios won't handle binary response data without the `responseType` parameter set to something other than `json` (which is the default). Therefore, this library now set both a non-`Accept: application/json` header (if one is not explicit defined in the spec) and `responseType: arraybuffer` parameter for binary responses. See https://axios-http.com/docs/req_config.
- Loading branch information
Showing
14 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { OperationParameter } from '../../../client/interfaces/OperationParameter'; | ||
|
||
export const getOperationExplicitAcceptHeader = (operationParameters: OperationParameter[]): string | null => { | ||
const header = operationParameters.find(operationParameter => { | ||
return operationParameter.in === 'header' && operationParameter.name.toLowerCase() === 'accept'; | ||
}); | ||
if (header) { | ||
return header.name; | ||
} | ||
return null; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { OperationResponse } from '../../../client/interfaces/OperationResponse'; | ||
|
||
export const getOperationImplicitAcceptHeader = (operationResponses: OperationResponse[]): string | null => { | ||
const operationResponse = operationResponses.find(operationResponses => { | ||
return operationResponses.in === 'response'; | ||
}); | ||
if (operationResponse) { | ||
return operationResponse.mediaType; | ||
} | ||
return null; | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { OperationResponse } from '../../../client/interfaces/OperationResponse'; | ||
|
||
export const getOperationResponseType = ( | ||
operationResponses: OperationResponse[] | ||
): 'arraybuffer' | 'document' | 'json' | 'text' | 'stream' | 'blob' | null => { | ||
const operationResponse = operationResponses.find(operationResponses => { | ||
return operationResponses.in === 'response'; | ||
}); | ||
if (operationResponse) { | ||
return operationResponse.format === 'binary' ? 'blob' : null; // Other cases: not implemented | ||
} | ||
return null; | ||
}; |
This file contains 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
This file contains 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
Oops, something went wrong.