Skip to content

Commit

Permalink
Merge branch 'master' into anklimenko/oneof-support
Browse files Browse the repository at this point in the history
  • Loading branch information
aleshchev authored May 10, 2024
2 parents 5e8a28d + 36a27ef commit 155fff9
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.idea

# code coverage
/coverage
Expand Down
15 changes: 15 additions & 0 deletions .snapshot/all/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ export class CategoryService extends BaseHttpService {
}
}

@Injectable({
providedIn: 'root'
})
export class FeedbackService extends BaseHttpService {
constructor(http: HttpClient) {
super(getBasePath('', '/api/feedback'), http);
}

public postFeedback(): Observable<void> {
return this.post<void>(
``,
);
}
}

@Injectable({
providedIn: 'root'
})
Expand Down
16 changes: 16 additions & 0 deletions .snapshot/withRequestOptions/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ export class CategoryService extends BaseHttpService {
}
}

@Injectable({
providedIn: 'root'
})
export class FeedbackService extends BaseHttpService {
constructor(http: HttpClient) {
super(getBasePath('', '/api/feedback'), http);
}

public postFeedback(options?: $types.TypeOrUndefined<IAngularHttpRequestOptions>): Observable<void> {
return this.post<void>(
``,
options,
);
}
}

@Injectable({
providedIn: 'root'
})
Expand Down
22 changes: 22 additions & 0 deletions __tests__/swagger/OpenAPIService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@ describe('OpenAPIService tests', () => {
expect(service.getSchemasByEndpoints(new Set<string>())).toEqual({});
});

test('response with not 200 code', () => {
const spec: IOpenAPI3 = {
...defaultSpec,
openapi: '3.0.1',
paths: {
'/product/test': {
post: {
responses: {
201: {
description: 'Created'
}
}
}
}
}
};

const service = new OpenAPIService(spec, guard);
const endpoints = service.getEndpoints();
expect(service.getSchemasByEndpoints(new Set<string>(endpoints))).toEqual({});
});

test('recursion', () => {
const spec: IOpenAPI3 = {
openapi: '3.0.1',
Expand Down
4 changes: 2 additions & 2 deletions src/services/ServiceMappingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class ServiceMappingService {
name: lowerFirst(actionName),
operation: method,
parameters: this.getUriParameters(operation.parameters),
returnType: this.getTypeInfo(operation.responses[200].content?.['application/json']?.schema, modelFinder),
returnType: this.getTypeInfo(operation.responses[200]?.content?.['application/json']?.schema, modelFinder),
originUri
};

Expand Down Expand Up @@ -224,6 +224,6 @@ export class ServiceMappingService {
}

private hasDownloadResponse(operation: IOpenAPI3Operation): boolean {
return Boolean(operation.responses[200].content?.['application/octet-stream']);
return Boolean(operation.responses[200]?.content?.['application/octet-stream']);
}
}
2 changes: 1 addition & 1 deletion src/swagger/OpenAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class OpenAPIService {
return [
...refs,
...this.getRefsFromSchema(operation.requestBody?.content['application/json']?.schema),
...this.getRefsFromSchema(operation.responses[200].content?.['application/json']?.schema)
...this.getRefsFromSchema(operation.responses[200]?.content?.['application/json']?.schema)
];
}

Expand Down
5 changes: 4 additions & 1 deletion src/swagger/v3/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IOpenAPI3Operation {
tags?: string[];
parameters?: IOpenAPI3Parameter[];
responses: {
200: {
200?: {
description?: 'Success';
content?: {
'application/json'?: {
Expand All @@ -20,6 +20,9 @@ export interface IOpenAPI3Operation {
};
};
};
201?: {
description?: 'Created';
};
};
requestBody?: {
content: {
Expand Down
20 changes: 19 additions & 1 deletion swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,24 @@
}
}
}
},
"/api/feedback": {
"post": {
"tags": [
"feedback"
],
"responses": {
"201": {
"description": "Created"
},
"400": {
"description": "Bad Request"
},
"500": {
"description": "Server Error"
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -791,4 +809,4 @@
}
}
}
}
}

0 comments on commit 155fff9

Please sign in to comment.