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

Duplicate resource URLs not handled #203

Closed
foxx opened this issue Jun 1, 2015 · 6 comments
Closed

Duplicate resource URLs not handled #203

foxx opened this issue Jun 1, 2015 · 6 comments

Comments

@foxx
Copy link

foxx commented Jun 1, 2015

If I specify the same resource URL twice, Snowcrash doesn't seem to detect that there is a duplicate;

## Create user [PUT /users]
## Create account [PUT /users]

I checked the specification and I cannot seem to find anything on how duplicate resource URLs are handled. In our use case, the only time there would be a duplicate resource URL would be in the event of human error, and I'm struggling to think of any situation where an API Blueprint would need to support duplicates.

On that basis, I'd like to suggest an amendment to the specification which checks if any duplicates exist, and raises an error (or at the very least a warning).

Thoughts?

@pksunkara
Copy link
Contributor

@foxx Can you give us the complete blueprint which is failing to detect a duplicate URL? Thanks.

@zdne
Copy link
Contributor

zdne commented Jun 2, 2015

Hey @foxx a bigger example would be good – are those endpoints nested under a resource or not?


If I specify the same resource URL twice, Snowcrash doesn't seem to detect that there is a duplicate;

Bottom line note: I am starting to question whether this is a correct behavior (constraining the designs to be resource - oriented only). See a possibly related discussion at #198 (comment)

@foxx
Copy link
Author

foxx commented Jun 5, 2015

I've been able to reproduce this with a clean blueprint, and it seems that a warning is already being raised. Should I close this ticket out, or is it still a valid problem?

FORMAT: 1A
HOST: http://polls.apiblueprint.org/

# test

Polls is a simple API allowing consumers to view polls and vote in them.

# Polls API Root [/]

This resource does not have any attributes. Instead it offers the initial
API affordances in the form of the links in the JSON body.

It is recommend to follow the “url” link values,
[Link](https://tools.ietf.org/html/rfc5988) or Location headers where
applicable to retrieve resources. Instead of constructing your own URLs,
to keep your client decoupled from implementation details.

## Create user [PUT /users]

+ Response 200 (application/json)

        {
            "questions_url": "/questions"
        }

## Create user [PUT /users]

+ Response 200 (application/json)

        {
            "questions_url": "/questions"
        }

@pksunkara
Copy link
Contributor

@foxx The parser will give warnings for duplicate URLs. You created the issue because you said that snowcrash doesn't detect duplicate URL which I think is a bug. Is there a blueprint where that happens?

is it still a valid problem?

What do you mean by that?

@foxx
Copy link
Author

foxx commented Jun 5, 2015

Sorry, this was a huge user error on my part.

It would seem that I did not properly check the warnings output when I initially posted this issue, as when I tried to reproduce it on the web editor the warning was clearly displayed, and when I re-checked protagonist the warning was displayed as well.

There could be legit situations where duplicate URLs are allowed I guess, therefore I'm going to mark the issue as closed.

Apologies for wasting your time on this guys :(

@foxx foxx closed this as completed Jun 5, 2015
@pksunkara
Copy link
Contributor

No worries @foxx 😄

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

3 participants