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

Fix custom operation_id's from OpenAPI #859

Merged
merged 2 commits into from Aug 24, 2020
Merged

Fix custom operation_id's from OpenAPI #859

merged 2 commits into from Aug 24, 2020

Conversation

fao89
Copy link
Member

@fao89 fao89 commented Aug 21, 2020

https://pulp.plan.io/issues/7341
closes #7341

Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html

@pulpbot
Copy link
Member

pulpbot commented Aug 21, 2020

Attached issue: https://pulp.plan.io/issues/7341

Comment on lines 70 to 72
action_name = getattr(self.view, "action", self.method.lower())
if action_name not in ["retrieve", "list", "destroy", "create"]:
return action_name
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm looking for customized action such as: sync and modify.
So if we get a customized action, we return it.

if self.method.lower() == "get" and self._is_list_view():
return "list"

return self.method_mapping[self.method.lower()]
Copy link
Member Author

Choose a reason for hiding this comment

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

the default actions are handled here

Comment on lines +302 to +307
tokenized_path = schema._tokenize_path()
tokenized_path = "_".join(
[t.replace("-", "_").replace("/", "_").lower() for t in tokenized_path]
)
action = schema.get_operation_id_action()
if f"{tokenized_path}_{action}" == operation["operationId"]:
Copy link
Member Author

Choose a reason for hiding this comment

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

this assures to return only the action for the bindings.
rpm_rpm_repositories_list -> list
rpm_rpm_repositories_sync - > sync

action = action_name.replace("destroy", "delete").replace("retrieve", "read")
tokenized_path = schema._tokenize_path()
tokenized_path = "_".join(
[t.replace("-", "_").replace("/", "_").lower() for t in tokenized_path]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain what's going on here?

Copy link
Member Author

@fao89 fao89 Aug 24, 2020

Choose a reason for hiding this comment

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

Please check if the docstrings I've added are enough or if I have to make an inline comment here

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.

None yet

4 participants