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

Documentation: API path parameter naming #4693

Open
HoffmannP opened this issue Aug 13, 2018 · 4 comments
Open

Documentation: API path parameter naming #4693

HoffmannP opened this issue Aug 13, 2018 · 4 comments
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented modifies/api This PR adds API routes or modifies them type/docs This PR mainly updates/creates documentation

Comments

@HoffmannP
Copy link
Contributor

HoffmannP commented Aug 13, 2018

  • Gitea version (or commit ref): 1.5

Description

All the path parameters in swagger (POST & GET are counted as one occurence)
45 {repo}
44 {owner}
22 {id}
20 {username}
12 {org}
8 {index}
2 {filepath}
1 {user}
1 {token}
1 {sha}
1 {ref}
1 {follower}
1 {followee}
1 {collaborator}
1 {branch}
1 {attachment_id}
1 {archive}

(jq -r '.paths | keys' swagger.v1.json | grep -o '\{[^\}]*\}' | sort | uniq -c | sort -rn)

As you can see there are 22 id and 8 index path parameter occurences in the swagger file. Most other parameters are distinctive and understandable form the first look. I'd recommend to rename these parameters to something easily understandable.

Just one example:

/repos/{owner}/{repo}/milestones/{id}
Get a milestone

rename the parameter:
{id} -> {milestone_id} (see attachment_id)
changing the description:
"id of the milestone" -> "id as obtainable from /repos/{owner}/{repo}/milestones"

@lafriks lafriks added the type/docs This PR mainly updates/creates documentation label Aug 13, 2018
@stale
Copy link

stale bot commented Jan 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Jan 14, 2019
@stale
Copy link

stale bot commented Feb 20, 2019

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Feb 20, 2019
@techknowlogick techknowlogick added modifies/api This PR adds API routes or modifies them issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented and removed issue/stale labels Feb 20, 2019
@6543
Copy link
Member

6543 commented Dec 31, 2019

@HoffmannP I find {id} more elegant and smalrer than {milestone_id} and the URL path determine its meaning so if path is .../milestone/{id} its very likely that the id is a milestone_id ?

I personaly would go the other way and would rename {attachment_id} to {id} so it follows pattern ...

@zeripath
Copy link
Contributor

The trouble is the swagger API is presented in multiple different formats, but most often without the URL to accompany it. In which case, the only context you have is the method name and parameter names. I can easily imagine that using id might be confusing in that situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented modifies/api This PR adds API routes or modifies them type/docs This PR mainly updates/creates documentation
Projects
None yet
Development

No branches or pull requests

5 participants