File tree 5 files changed +10
-0
lines changed
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";
22
22
23
23
const CONTENT_KIND = {
24
24
JSON : "JSON" ,
25
+ JSON_API : "JSON_API" ,
25
26
URL_ENCODED : "URL_ENCODED" ,
26
27
FORM_DATA : "FORM_DATA" ,
27
28
IMAGE : "IMAGE" ,
@@ -280,6 +281,10 @@ export class SchemaRoutes {
280
281
) ;
281
282
282
283
getContentKind = ( contentTypes ) => {
284
+ if ( contentTypes . includes ( "application/vnd.api+json" ) ) {
285
+ return CONTENT_KIND . JSON_API ;
286
+ }
287
+
283
288
if (
284
289
contentTypes . some ( ( contentType ) =>
285
290
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
32
32
33
33
export enum ContentType {
34
34
Json = "application/json",
35
+ JsonApi = "application/vnd.api+json",
35
36
FormData = "multipart/form-data",
36
37
UrlEncoded = "application/x-www-form-urlencoded",
37
38
Text = "text/plain",
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ type CancelToken = Symbol | string | number;
43
43
44
44
export enum ContentType {
45
45
Json = "application/json",
46
+ JsonApi = "application/vnd.api+json",
46
47
FormData = "multipart/form-data",
47
48
UrlEncoded = "application/x-www-form-urlencoded",
48
49
Text = "text/plain",
@@ -103,6 +104,7 @@ export class HttpClient<SecurityDataType = unknown> {
103
104
104
105
private contentFormatters: Record<ContentType , (input: any) => any> = {
105
106
[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,
106
108
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
107
109
[ContentType.FormData]: (input: any) =>
108
110
Object.keys(input || {}).reduce((formData, key) => {
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ const wrapperArgs = _
48
48
// RequestParams["type"]
49
49
const requestContentKind = {
50
50
" JSON" : " ContentType.Json" ,
51
+ " JSON_API" : " ContentType.JsonApi" ,
51
52
" URL_ENCODED" : " ContentType.UrlEncoded" ,
52
53
" FORM_DATA" : " ContentType.FormData" ,
53
54
" TEXT" : " ContentType.Text" ,
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ const wrapperArgs = _
48
48
// RequestParams["type"]
49
49
const requestContentKind = {
50
50
" JSON" : " ContentType.Json" ,
51
+ " JSON_API" : " ContentType.JsonApi" ,
51
52
" URL_ENCODED" : " ContentType.UrlEncoded" ,
52
53
" FORM_DATA" : " ContentType.FormData" ,
53
54
" TEXT" : " ContentType.Text" ,
You can’t perform that action at this time.
0 commit comments