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

Don't override references when using a ResponseSchema for different cases #45

Open
gabisurita opened this issue Jan 22, 2017 · 2 comments

Comments

@gabisurita
Copy link
Collaborator

gabisurita commented Jan 22, 2017

The current implementation overrides the references when using a same schema for different responses cases. e.g:

class ErrorSchema(colander.MappingSchema):

    code = colander.SchemaNode(colander.Integer())
    message = colander.SchemaNode(colander.String())

response_schemas = {
    '400': ErrorResponseSchema(
        description="The request is invalid."),
    '401': ErrorResponseSchema(
        description="The request is missing authentication headers."),
}

Both will be at #/responses/ErrorResponseSchema

@gabisurita gabisurita added the bug label Jan 22, 2017
@gabisurita
Copy link
Collaborator Author

gabisurita commented Jan 23, 2017

One approach would be to require a unique name for the response. Thoughts?

@glasserc
Copy link
Contributor

Well, definitely throwing an exception if we get to this case is better than silently overriding it... but not much better. One thing we could do is generate unique names, calling one #/responses/ErrorResponseSchema1 and the other #/responses/ErrorResponseSchema2, but this seems like it could be pretty brittle unless we come up with an unambiguous/canonical name for the responses. (Do clients use the reference paths for anything?) Maybe we could detect this case and just not make references in this case, but just let the responses live underneath each operation?

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

2 participants