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

defining exact response is cumbersome #1428

Closed
halmai opened this issue Jul 27, 2017 · 2 comments
Closed

defining exact response is cumbersome #1428

halmai opened this issue Jul 27, 2017 · 2 comments

Comments

@halmai
Copy link

halmai commented Jul 27, 2017

There are some cases when the response JSON structure returned by an API endpoint is always the same. I mean, I would like to specify in the API specification that the result is

    {
        "result": "ERROR",
        "error_msg": "ERROR__NO_PERMISSION"
    }

The best way I found to describe this, is a 1-element enum for each field. It is quite verbose so it would be nice to have a value member describing exact values like this:

definitions:
    OK-response:
        type: object
        properties:
            result: 
                type: string
                value: "ERROR"
            error_msg:
                type: string
                value: "ERROR__NO_PERMISSION"

It would be even better to define constant responses with complete JSON description, similarly to this one:

definitions:
    OK-response:
        object_json: """
            {
                result: "ERROR",
                error_msg: "ERROR__NO_PERMISSION"
            }
        """
@webron
Copy link
Contributor

webron commented Jul 28, 2017

This is an issue for the spec, not swagger-editor. We just follow what the spec allows. If you'd like to try and see a change, you can file a ticket on the spec's repo.

That said, considering we're using a subset of JSON Schema, it's very unlikely that we'd deviate from that in the spec.

@webron webron closed this as completed Jul 28, 2017
@halmai
Copy link
Author

halmai commented Aug 5, 2017

Thanks, I issued a feature request in order to get this way of specifying a constant value:
OAI/OpenAPI-Specification#1313

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

No branches or pull requests

2 participants