Skip to content

Commit

Permalink
Infer The type
Browse files Browse the repository at this point in the history
  • Loading branch information
moetazbrayek1 committed Dec 30, 2023
1 parent edde310 commit 41a4767
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/common/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,8 @@ function makeRequestsDeclaration(
);
}

type HttpMethods =
| "get"
| "delete"
| "post"
| "put"
| "patch"
| "head"
| "options";
const methods = ['get', 'delete', 'post', 'put', 'patch', 'head', 'options'] as const;
type HttpMethods = typeof methods[number];

function makeRequestsPropertyAssignment(
$refs: SwaggerParser.$Refs,
Expand All @@ -150,15 +144,6 @@ function makeRequestsPropertyAssignment(
) {
const requests: ts.PropertyAssignment[] = [];
const params = item.parameters;
const methods: HttpMethods[] = [
"get",
"delete",
"post",
"put",
"patch",
"head",
"options",
];

methods.forEach((method) => {
const operation: OpenAPIV3.OperationObject | undefined = item[method];
Expand All @@ -172,6 +157,7 @@ function makeRequestsPropertyAssignment(
return requests;
}


function isRequestBodyObject(
obj: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject
): obj is OpenAPIV3.RequestBodyObject {
Expand Down

0 comments on commit 41a4767

Please sign in to comment.