Skip to content

resource methods: deduplicate request types between regular and body methods#166

Draft
declanvong wants to merge 2 commits intomasterfrom
declan/deduplicate-request-types
Draft

resource methods: deduplicate request types between regular and body methods#166
declanvong wants to merge 2 commits intomasterfrom
declan/deduplicate-request-types

Conversation

@declanvong
Copy link
Copy Markdown
Collaborator

No description provided.


if (method.response) {
const schema = schemas[checkExists(method.response.$ref)];
const schemaName = method.response.$ref;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated refactoring

return dir;
}

/**
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer consumed or needed, since we've replaced it with a simpler method write.

...method.parameters,
// Construct request type, e.g. get(...) on InvitationsResource -> GetInvitationsRequest
const methodType = checkExists(getName(method.id));
const methodParts = method.id?.split('.');
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As raised in the previous PR, we weren't including the parent path down to the resource method, which meant we'd get some interface duplication, e.g. NotesResource in the containeranalysis API.

Using method.id (looks something like containeranalysis.projects.notes.occurrences.list) instead of just resourceName (just notes) will let us process it into something like ListProjectsNotesOccurencesRequest, which is fully namespaced and shouldn't conflict.

Comment on lines +486 to +493
if (resource.resources) {
_.forEach(resource.resources, (_, childResourceName) => {
const childResourceInterfaceName = getResourceTypeName(
childResourceName
);
out.property(childResourceName, childResourceInterfaceName);
});
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has just been moved up from below, wasn't touched

@@ -1,17 +1,18 @@
import {promisify} from 'bluebird';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My import sorter auto formatted this to be alphabetical 😅

@Maxim-Mazurok
Copy link
Copy Markdown
Owner

Thank you for not giving up on this!
CI failed on linting, could you take a look, please?

@declanvong
Copy link
Copy Markdown
Collaborator Author

haha, not completely ready yet, will assign you when it's done!

@Maxim-Mazurok Maxim-Mazurok marked this pull request as draft December 9, 2023 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants