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

Issue with enum query parameter with a default value #287

Open
AlJohri opened this issue Mar 19, 2017 · 2 comments
Open

Issue with enum query parameter with a default value #287

AlJohri opened this issue Mar 19, 2017 · 2 comments
Labels
bug upstream-problem The problem is caused by a bug in a dependency.

Comments

@AlJohri
Copy link

AlJohri commented Mar 19, 2017

If a query parameter is of type enum and has a default value, the swagger parameter for default should be appropriately set and required should be set to true.

Here is an example below.

what's happening

(GET "/all/" request
     :description "Return a list of articles."
     :return [(dissoc t/Article :is_html :text)]
     :responses default-responses
     :query-params [{sort :- (describe (s/enum :published_at :last_processed_at) "The sort type. Defaults to published_at.") "published_at"}]
     (return (domain/get-all-articles db (org request) :days 1)))

The sort parameter above can be either published_at or last_processed_at where it defaults to the former.

The JSON output for the route above is:

"parameters": [
  {
    "in": "query",
    "name": "sort",
    "description": "The sort type. Defaults to published_at.",
    "required": false,
    "type": "string",
    "enum": [
      "last_processed_at",
      "published_at"
    ]
  }
]

And the UI renders like this:

screen shot 2017-03-18 at 9 59 34 pm

expectation

I would expect the select box in the UI to start off with the published_at pre-selected and not allow a nil option.
I would expect the json output to have required set to true and a default value set to published_at.

Thanks for your time!

@ikitommi
Copy link
Member

Missed this, sorry. Wrote an issue to ring-swagger, which does the conversion to swagger json schema.

@ikitommi ikitommi added the bug label May 26, 2017
@miikka miikka added the upstream-problem The problem is caused by a bug in a dependency. label Nov 2, 2019
@lasiltan
Copy link

lasiltan commented Feb 4, 2020

Sorry to hijack this but what is that describe function?

Nevermind, compojure.api.sweet/describe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug upstream-problem The problem is caused by a bug in a dependency.
Projects
None yet
Development

No branches or pull requests

4 participants