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

Path segment variable with visible name? #377

Open
s303 opened this issue Feb 1, 2017 · 5 comments
Open

Path segment variable with visible name? #377

s303 opened this issue Feb 1, 2017 · 5 comments

Comments

@s303
Copy link

s303 commented Feb 1, 2017

Looks like there is no way to render a parameter with visible name not as a query parameter.

For example: I have a commits (/commits) resource with page and size query parameters. And I would like to have ability to filter commits by project, and I would like to have it as an optional path parameter with name, like /project/windows95/commits. Is it possible?

Maybe some form of "form-style path operator" ({/project}) could be introduced? Like:

FORMAT: 1A
# Sample API
## Read commits [GET /{/project}/commits{?page,size}]
+ Parameters
  + page: 1 (number)
  + size: 1 (optional, number)
  + project: `windows95` (optional, string)
+ Response 200 (application/json)

That will be rendered as:
/project/windows95/commits?page=1

@w-vi
Copy link
Member

w-vi commented Feb 1, 2017

Hi @sniff

## Read commits [GET /{project}/commits{?page,size}]

+ Parameters
    + page: 1 (number)
    + size: 1 (optional, number)
    + project: `windows95` (optional, string)

+ Response 200 (application/json)

is exactly what you ask for if I am reading correctly.

Another example with parameters https://apiblueprint.org/documentation/examples/07-parameters.html

@s303
Copy link
Author

s303 commented Feb 1, 2017

@w-vi No, it does not. This will add only parameter value to URL (windows95) without parameter name (project) itself.

Your example will be rendered as /windows95/commits?page=1 if project is present, and I would like to have /project/windows95/commits?page=1.

I don't want to describe two methods for with 100% same parameters (page, size...) like:

FORMAT: 1A
# Sample API
## Read commits [GET /commits{?page,size}]
+ Parameters
  + page: 1 (number)
  + size: 1 (optional, number)
+ Response 200 (application/json)
## Read commits for project [GET /project/{projectName}/commits{?page,size}]
+ Parameters
  + page: 1 (number)
  + size: 1 (optional, number)
  + projectName: `windows95` (optional, string)
+ Response 200 (application/json)

@w-vi w-vi reopened this Feb 1, 2017
@FranklinYu
Copy link

How about shared parameter section:

FORMAT: 1A

# Sample API

## Commit collection [/commits{?page,size}]

+ Parameters
    + page: 1 (number)
    + size: 1 (optional, number)

### Read commits [GET /commits{?page,size}]

+ Response 200 (application/json)

### Read commits for project [GET /project/{projectName}/commits{?page,size}]

+ Parameters
    + projectName: `windows95` (optional, string)
+ Response 200 (application/json)

@pksunkara
Copy link
Contributor

You can inherit parameters for an action from a resource currently.

@s303
Copy link
Author

s303 commented May 29, 2017

@FranklinYu Could be an option, but it still requires to duplicate descriptions and Responses for both sections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants