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

Last param should match slashes #43

Closed
raffis opened this issue Jan 23, 2023 · 2 comments · Fixed by #44
Closed

Last param should match slashes #43

raffis opened this issue Jan 23, 2023 · 2 comments · Fixed by #44

Comments

@raffis
Copy link
Contributor

raffis commented Jan 23, 2023

Currently I have to override this endpoint pattern:

var deleteReposIssuesLabelsByOwnerByRepoByIssueNumberByName mock.EndpointPattern = mock.EndpointPattern{
	Pattern: "/repos/{owner}/{repo}/issues/{issue_number}/labels/{name:.*}",
	Method:  "DELETE",
}

The default is to generate it like: "/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}"
However mux would not match an URL like repos/foo/bar/issues/3/labels/prio/high

The label name contains a slash which is valid in github and that api call also works. However it does not work using the mock as mux does not route it correctly and it ends in mock response not found for /repos/foo/bar/issues/3/labels/prio/high

Happy to provide a fix for the generator if this is considered a bug.

@migueleliasweb
Copy link
Owner

Hi @raffis , there are some other known edge cases like this in Github's API. They're quite inconsistent.

As you can see in https://github.com/migueleliasweb/go-github-mock/blob/master/src/gen/gen_mutations.go#L9, there have been a few instances already. What that mutator does is basically intercept the generation process and mutate the final param to be something that would accept any character. Have a look.

I'm happy to let you add this use-case to that file.

Let me know your thoughts.

@raffis
Copy link
Contributor Author

raffis commented Jan 24, 2023

Let me know your thoughts.

Thats perfect, thanks 👍🏻 , see #44

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 a pull request may close this issue.

2 participants