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

Support for all Swagger Schema property definitions #52

Closed
ikitommi opened this issue Jun 25, 2015 · 14 comments
Closed

Support for all Swagger Schema property definitions #52

ikitommi opened this issue Jun 25, 2015 · 14 comments

Comments

@ikitommi
Copy link
Member

thigs like :maximum, :minimum etc. https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#schema-object

Also, schema.core/both should try to merge in these definitions so that:

(s/both String (min-length 6) (max-length 10))

would work.

@Deraen
Copy link
Member

Deraen commented Aug 15, 2015

These Schemas should be provided in schema-tools (metosin/schema-tools#16).

@shmish111
Copy link

Are PRs going to be accepted for this? For example :tags and others aren't anywhere in https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/swagger2_schema.clj but it would be quite easy to add them in.

@ikitommi
Copy link
Member Author

Not everything be represented with Schemas (e.g. the Swagger Response definitions) without extending the Schema itself, but most common stuff works, so go ahead.

@ikitommi
Copy link
Member Author

There was more coverage before: 1acba7e

@ikitommi
Copy link
Member Author

Actually, would a full sample work better? like https://github.com/technomancy/leiningen/blob/master/sample.project.clj

There is already the JSON Schema validator with Ring Swagger, which is 100% proof.

@shmish111
Copy link

I personally was looking for a full Schema schema so that I can use it in
another project at another validation point, I would like to merge some or
all of the swagger schema. Any idea why
9cf5d1b#diff-7f6c5b35809673f3f7de2988db285329
was made? What's the problem with a full schema definition (at least for
things that are not tough like tags)?

On Wed, Jan 27, 2016 at 2:39 PM, Tommi Reiman [email protected]
wrote:

Actually, would a full sample work better? like
https://github.com/technomancy/leiningen/blob/master/sample.project.clj

There is already the JSON Schema validator with Ring Swagger, which is
100% proof.


Reply to this email directly or view it on GitHub
#52 (comment)
.

@shmish111
Copy link

Hi Guys, any advice on this? I just started a project yesterday that would really benefit from this, I just would like to know why it was removed in the commit I linked to above so that hopefully whatever reason that was can be fixed?

@ikitommi
Copy link
Member Author

ikitommi commented Feb 2, 2016

Hi, the schema was removed as it was not complete, would be an extra maintenance effort and wasn't that readable anymore (lot's of nesting & regex-stuff) and there was/is the JSON Schema validator, which is bullet-proof.

But also understand you point-of-view, Schema would provide faster feedback-loop in the pure clojure land. I propose we'll have two schemas:

  1. the absolute minimum, only with the ring-swagger changes to the original swagger spec (currently just the :paths, which use Prismatic Schema instead of JSON Schema, so not even with the info-part)

  2. another Schema, with more coverage.

Could be in the same namespace, with just describing names. The users of the lib could use the more complete Schema if they wish. And if most people want to use that, could be the only version in the future.

what do you think? if ok, looking forward to the PR :)

@shmish111
Copy link

ok, 1 problem I've come across is that :parameters in ring-swagger is not correct, it is in a format like ring uses but the swagger spec requires it to be more explicit. As this is an optional schema I'm defining, I guess I should stick to the swagger spec totally and if someone uses it then they will need to use some schema coercion for ring-style parameters. Does that sound ok? http://swagger.io/specification/#parameterObject

@shmish111
Copy link

Sorry, I understand what's going on. So my question is, should this schema I'm creating be the correct swagger spec? I think it should, then people (or possibly even ring-swagger) can use the coercion functions that already exist in ring-swagger to coerce whatever they have into a fully valid swagger schema. What do you think?

@ikitommi
Copy link
Member Author

ikitommi commented Feb 2, 2016

The whole idea in ring-swagger is that you can work with the Prismatic Schemas under :paths (and :definitions get generated from those). Because of that, the schema for :paths is simplified => I don't see a point in describing the generated swagger spec on :paths or :definitions as users of ring-swagger should not be interested in those. The generated end-results can be validated with ring.swagger.validator/validate.

Did this answer your question?

@shmish111
Copy link

Hmm good point, no point in putting in the schema things that will always be the same for clojure values. Ok, that makes sense, I'll adjust accordingly.

@shmish111
Copy link

I've created #86 as a first attempt, please let me know what you think.

@ikitommi
Copy link
Member Author

#86 is already merged, let's reopen this if there is still need.

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

3 participants