Skip to content

Commit

Permalink
handleResponse doesn't have to be a method
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Sep 19, 2024
1 parent 4519b05 commit 54de40f
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions src/api/autogen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,27 +426,27 @@ class TypeContext {
});
});
}
}

static handleResponse(
method: 'GET' | 'PUT',
device: Device,
canonicalMethodName: string,
{
responses: {
200: success,
400: error400,
500: error500,
...otherResponses
} = err('Missing responses')
}: OpenAPIV3_1.OperationObject
) {
assertEmpty(otherResponses, 'Unexpected response status codes');
return new TypeContext(method, 'Response', device).handleContent(
canonicalMethodName,
'application/json',
success
);
}
function handleResponse(
method: 'GET' | 'PUT',
device: Device,
canonicalMethodName: string,
{
responses: {
200: success,
400: error400,
500: error500,
...otherResponses
} = err('Missing responses')
}: OpenAPIV3_1.OperationObject
) {
assertEmpty(otherResponses, 'Unexpected response status codes');
return new TypeContext(method, 'Response', device).handleContent(
canonicalMethodName,
'application/json',
success
);
}

for (let [path, methods = err('Missing methods')] of Object.entries(
Expand Down Expand Up @@ -538,12 +538,7 @@ for (let [path, methods = err('Missing methods')] of Object.entries(
path: methodPath,
doc: getDoc(get),
resolvedArgs,
returnType: TypeContext.handleResponse(
'GET',
device,
canonicalMethodName,
get
)
returnType: handleResponse('GET', device, canonicalMethodName, get)
});
});

Expand Down

0 comments on commit 54de40f

Please sign in to comment.