Skip to content

Commit 7fec78e

Browse files
Merge pull request #266 from openapi-ui/main
feat: support extra apifox config
2 parents f0d3964 + c12233e commit 7fec78e

File tree

4 files changed

+63
-57
lines changed

4 files changed

+63
-57
lines changed

.changeset/clean-garlics-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
feat: support extra apifox config

pnpm-lock.yaml

Lines changed: 38 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/type.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,30 @@ export type ReadConfigOptions = MutuallyExclusiveWithFallback<
120120
> & { fallbackName: string };
121121

122122
export interface APIFoxBody {
123-
scope: {
123+
scope?: {
124124
type?: 'ALL' | 'SELECTED_TAGS';
125125
includeTags?: string[];
126126
excludeTags?: string[];
127127
};
128128
options?: {
129-
includeApifoxExtensionProperties: boolean;
130-
addFoldersToTags: boolean;
129+
includeApifoxExtensionProperties?: boolean;
130+
addFoldersToTags?: boolean;
131131
};
132132
oasVersion?: '2.0' | '3.0' | '3.1';
133133
exportFormat?: 'JSON' | 'YAML';
134134
environmentIds?: string[];
135135
}
136-
export interface GetSchemaByApifoxProps {
136+
137+
export interface GetSchemaByApifoxProps
138+
extends Pick<APIFoxBody, 'oasVersion' | 'exportFormat'>,
139+
Pick<
140+
APIFoxBody['options'],
141+
'includeApifoxExtensionProperties' | 'addFoldersToTags'
142+
> {
137143
projectId: string;
144+
apifoxToken: string;
138145
locale?: string;
139146
apifoxVersion?: string;
140147
includeTags?: (string | RegExp)[];
141148
excludeTags?: string[];
142-
apifoxToken: string;
143149
}

src/util.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,22 @@ const getSchemaByApifox = async ({
7979
includeTags,
8080
excludeTags = [],
8181
apifoxToken,
82+
oasVersion = '3.0',
83+
exportFormat = 'JSON',
84+
includeApifoxExtensionProperties = false,
85+
addFoldersToTags = false,
8286
}: GetSchemaByApifoxProps): Promise<OpenAPI.Document | null> => {
8387
try {
8488
const body: APIFoxBody = {
8589
scope: {
8690
excludeTags,
8791
},
8892
options: {
89-
includeApifoxExtensionProperties: false,
90-
addFoldersToTags: false,
93+
includeApifoxExtensionProperties,
94+
addFoldersToTags,
9195
},
92-
oasVersion: '3.0',
93-
exportFormat: 'JSON',
96+
oasVersion,
97+
exportFormat,
9498
};
9599
const tags = getApifoxIncludeTags(includeTags);
96100

@@ -103,7 +107,7 @@ const getSchemaByApifox = async ({
103107

104108
const res = await axios.post(
105109
`https://api.apifox.com/v1/projects/${projectId}/export-openapi?locale=${locale}`,
106-
{},
110+
body,
107111
{
108112
headers: {
109113
'X-Apifox-Api-Version': apifoxVersion,

0 commit comments

Comments
 (0)