Skip to content

Commit 41a7629

Browse files
Added support for response type:
Added new methods to "api model": - isResponseTypeText - isResponseTypeJson - isResponseTypeXML - isResponseTypeFile
1 parent d985210 commit 41a7629

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/models/api.model.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class ApiModel implements PhysycalFile {
1818
queryParams: ModelAttributessModel;
1919
requestContentType?: string;
2020
requestBody: ModelAttributessModel;
21+
responseContentType?: string;
2122
response: ModelAttributessModel;
2223

2324
get name(): string {
@@ -40,6 +41,26 @@ export class ApiModel implements PhysycalFile {
4041
return this.response?.isArray;
4142
}
4243

44+
get isResponseTypeText(): boolean {
45+
return this.responseContentType?.indexOf('text/') === 0;
46+
}
47+
48+
get isResponseTypeJson(): boolean {
49+
return this.responseContentType === 'application/json';
50+
}
51+
52+
get isResponseTypeXML(): boolean {
53+
return this.responseContentType === 'application/xml';
54+
}
55+
56+
get isResponseTypeFile(): boolean {
57+
return (
58+
!this.isResponseTypeText &&
59+
!this.isResponseTypeJson &&
60+
!this.isResponseTypeXML
61+
);
62+
}
63+
4364
get responseArrayLevelsRepeater(): any[] {
4465
return this.response?.arrayLevelsRepeater;
4566
}

src/services/parsers/open-api-v3/api-parser.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class APIParserService extends ParserBaseService {
105105
if (this.isResponseObject(response)) {
106106
const keys = Object.keys(response.content);
107107
const mainKey = keys[0];
108+
apiModel.responseContentType = mainKey;
108109
apiModel.response = this.parseSchema(
109110
response.content[mainKey].schema,
110111
getApiDefaultModelName(apiModel, 'Response'),

0 commit comments

Comments
 (0)