Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

declanvong
Copy link
Collaborator

No description provided.

@@ -417,10 +419,11 @@ function getMethodReturn(
const name = schemas['Request'] ? 'client.Request' : 'Request';

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

Choose a reason for hiding this comment

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

Unrelated refactoring

@@ -461,34 +464,6 @@ export class App {
return dir;
}

/**
Copy link
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
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
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
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
Owner

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

@declanvong
Copy link
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