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

Handle Schema default values (was: How to compose parameters) #174

Open
t-jones opened this issue Nov 16, 2015 · 8 comments
Open

Handle Schema default values (was: How to compose parameters) #174

t-jones opened this issue Nov 16, 2015 · 8 comments

Comments

@t-jones
Copy link

t-jones commented Nov 16, 2015

I have a set of services with a common set of query parameters. What's the best way to reuse/compose their definition across a set of services? I've been playing with the GET* and friends macro, learning about letk/plumbing, but can't see a way to make it happen at this level of the stack. Is it possible, and what am I missing?

It's entirely possible I'm thinking about this problem incorrectly, so open to feedback on that as well.

@Deraen
Copy link
Member

Deraen commented Nov 16, 2015

I don't think this is possible with letk/plumbing syntax.

You can use :query to set the Schema using normal Schema: https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L205. Though this doesn't solve destructuring.

@t-jones
Copy link
Author

t-jones commented Nov 17, 2015

Is it still possible to attach swagger meta-data via describe on the schema element when using :query? Also, how about default values? I saw a patch for this in Schema, but not sure how to go about it.

@t-jones
Copy link
Author

t-jones commented Nov 17, 2015

Ok, answered this myself; you can attach metadata with describe; not sure about defaults. But this gets me about 80% there!

@t-jones
Copy link
Author

t-jones commented Nov 19, 2015

@Deraen any thoughts on handling default values? wrapping keys in s/optional-key provides optional parameters, but it looks like defaults are provided solely by letk. Any chance you'll be using this soon?
plumatic/plumbing@961fa0d

@Deraen
Copy link
Member

Deraen commented Nov 20, 2015

@t-jones Yes we are planning on using metadata set by plumbing letk. But anyway, that won't help in this case, the metadata is purely for documentation, the default value itself needs to still be handled by destructuring or some other way.

@ikitommi
Copy link
Member

There is a partial solution for handling defaults with custom coercion matcher in the Plumbing google group. Idea is to finalize it and add it to our schema-tools, enabling schema defaults for wider audience. I'm on vacation, so feel free to implement wirh PR.

@ikitommi
Copy link
Member

related: metosin/schema-tools#25.

@ikitommi ikitommi changed the title How to compose parameters Handle Schema default values (was: How to compose parameters) Jan 18, 2016
@miikka
Copy link
Contributor

miikka commented Nov 2, 2019

Possibly related: metosin/ring-swagger#138

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