File tree Expand file tree Collapse file tree 5 files changed +10
-0
lines changed
Expand file tree Collapse file tree 5 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { SpecificArgNameResolver } from "./util/specific-arg-name-resolver.js";
2222
2323const CONTENT_KIND = {
2424 JSON : "JSON" ,
25+ JSON_API : "JSON_API" ,
2526 URL_ENCODED : "URL_ENCODED" ,
2627 FORM_DATA : "FORM_DATA" ,
2728 IMAGE : "IMAGE" ,
@@ -280,6 +281,10 @@ export class SchemaRoutes {
280281 ) ;
281282
282283 getContentKind = ( contentTypes ) => {
284+ if ( contentTypes . includes ( "application/vnd.api+json" ) ) {
285+ return CONTENT_KIND . JSON_API ;
286+ }
287+
283288 if (
284289 contentTypes . some ( ( contentType ) =>
285290 contentType . startsWith ( "application/json" ) ,
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export interface ApiConfig<SecurityDataType = unknown> extends Omit<AxiosRequest
3232
3333export enum ContentType {
3434 Json = "application/json",
35+ JsonApi = "application/vnd.api+json",
3536 FormData = "multipart/form-data",
3637 UrlEncoded = "application/x-www-form-urlencoded",
3738 Text = "text/plain",
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ type CancelToken = Symbol | string | number;
4343
4444export enum ContentType {
4545 Json = "application/json",
46+ JsonApi = "application/vnd.api+json",
4647 FormData = "multipart/form-data",
4748 UrlEncoded = "application/x-www-form-urlencoded",
4849 Text = "text/plain",
@@ -103,6 +104,7 @@ export class HttpClient<SecurityDataType = unknown> {
103104
104105 private contentFormatters: Record<ContentType , (input: any) => any> = {
105106 [ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
107+ [ContentType.JsonApi]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
106108 [ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
107109 [ContentType.FormData]: (input: any) =>
108110 Object.keys(input || {}).reduce((formData, key) => {
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ const wrapperArgs = _
4848// RequestParams["type"]
4949const requestContentKind = {
5050 " JSON" : " ContentType.Json" ,
51+ " JSON_API" : " ContentType.JsonApi" ,
5152 " URL_ENCODED" : " ContentType.UrlEncoded" ,
5253 " FORM_DATA" : " ContentType.FormData" ,
5354 " TEXT" : " ContentType.Text" ,
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ const wrapperArgs = _
4848// RequestParams["type"]
4949const requestContentKind = {
5050 " JSON" : " ContentType.Json" ,
51+ " JSON_API" : " ContentType.JsonApi" ,
5152 " URL_ENCODED" : " ContentType.UrlEncoded" ,
5253 " FORM_DATA" : " ContentType.FormData" ,
5354 " TEXT" : " ContentType.Text" ,
You can’t perform that action at this time.
0 commit comments