-
Notifications
You must be signed in to change notification settings - Fork 3
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
inject constraints & hints into generation process #2
Comments
Hey :-) Thanks for your work on schema-gen! Right now, I have a schema for {:type {:v :http},
:url {:p? #<core$uri_QMARK_ schema_contrib.core$uri_QMARK_@7d625686>, :pred-name URI},
{:k :method} {:vs #{:get :patch :delete :head :post :put}}} So, the :url key uses the schema-contrib (which you're one of the main authors of, looks like; thanks for that, too!) URL schema. schema-contrib has some generator stuff but nothing that seems to hook into schema-gen and nothing for the URL type. So, two questions:
|
Suggestion: add a |
After some more careful reading of the code, it appears that an implementation for Would you like these to be contributed to this library? |
Hey @lvh. Thank you for using this and schema-contrib! I plan to give your posts more thought later, but I think extending it within your codebase would be the best approach, as, currently, the goal is to get schema-gen to work for the prismatic-schema's core functionality. Though, I think it'd be great to have your example in the README of the contrib side...i.e. something related to using schema-gen w/ schema-contrib, which would be awesome. In my work at SFX, previously, we did the same thing and also created a set of custom generators that combined contrib and the more generic ones. P.S. as you may have noticed by now, schema->gen* (star) is just an additional dispatch-type... which the public interface, schema->gen calls into. |
Are there any hints about how to handle predicates in the schema definitions? At the moment I'm getting an exception thrown but can I add a multi method for schema->gen* for a specific key somehow? |
predicates are tricky because in test.check a predicate used with I'd like this to be better but don't have any general ideas. I feel like it would likely involve using a more specific set of schema tools that are designed with generation in mind. If you describe your current use case I could speculate about how that might fit. |
@gfredericks's right. Predicates make things difficult, but it's also something I've wanted to put more thought into. |
I have a fairly straightforward constraint just now - strings of a maximum length. Ideally the generated values would respect this constraint. Would an approach be to hint the generator using metadata? Thanks Dave. On 1 Jun 2015 17:17 +0100, Zeeshan Lakhaninotifications@github.com, wrote:
|
yeah some kind of special schema that has info for schema-gen would work. You couldn't use |
I've done some work on this that's really specific to our data at sfx (and within private repos). Will look into doing something more general.
Related Issue/Comment
The text was updated successfully, but these errors were encountered: