Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/generate/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,28 @@ const cleanPathUrl = (path: string) => {
.join('.');
};

/*
/apps/{app_id}/files
/apps/{app_id}/files/{file_id}
/apps/{app_id}/files/{file_id}/cancel
*/
export const generateAPIMethods = (schema: OpenAPI3): string => {
const allMethods: Map<string, MethodOptions> = new Map();

const allPaths = new Map(Object.entries(schema.paths ?? {}));

allPaths.forEach((methods, endpoint) => {
/* if (endpoint !== '/apps/{app_id}/workflows/{workflow_id}/runs') {
return;
} */

Object.entries(methods).forEach(([method, details]) => {
const apiMethod = buildAPIMethodObject(schema, endpoint, method, details);

const methodsToPush = [apiMethod];

//

if (apiMethod.stream) {
apiMethod.stream = false;

Expand All @@ -118,9 +129,13 @@ export const generateAPIMethods = (schema: OpenAPI3): string => {
});
}

//

methodsToPush.forEach(apiMethod => {
const matchingPaths = [...allPaths.keys()].filter(
path => path !== endpoint && path.startsWith(endpoint),
const matchingPaths = [...allPaths.entries()].filter(
([path, item]) =>
(path === endpoint && Object.keys(item).length > 1) ||
(path !== endpoint && path.startsWith(endpoint)),
);

if (methodsToPush.length === 1 && !matchingPaths.length) {
Expand Down
Loading