swaggydoc icon indicating copy to clipboard operation
swaggydoc copied to clipboard

Further improvements to constraints handling

Open felipecao opened this issue 9 years ago • 4 comments

I've done some improvement on how constraints are handled in SwaggyDataService. This way, regular properties and constraints remain separated and require less changes on swagger-ui.

felipecao avatar Apr 16 '15 08:04 felipecao

Hi, rahulsom, is there something I could do to help with merging this pull request? Is there anything wrong with it?

Thanks!

felipecao avatar Apr 20 '15 12:04 felipecao

@felipecao Actually the constraints.constraints seems to be non standard swagger. I've implemented support for enum, minimum and maximum documented here. This should take care of most commonly used grails constraints. Other stuff will have to wait until this plugin can be made to use swagger spec 2.0.

rahulsom avatar Apr 20 '15 16:04 rahulsom

Hi, @rahulsom, thanks for the feedback.

To answer your question, yes, constraints is non standard swagger. Like I said on pull request https://github.com/rahulsom/swaggydoc/pull/20, the intention is to enrich both swagger and swaggydoc with Grails constraints information. I'll make a pull request for swagger-ui to support that as well.

About enum, minimum, maximum, we wanted to display information beyond that, using constraints like nullable, blank, creditCard, etc, in an easy to integrate way. As you had accepted my first pull request, I thought everything was fine, can we sort this out somehow? Please notice that my code changes do not request past or future users to make use of it, they do not introduce any breaking changes.

But doesn't the plugin already support swagger spec 2.0? As per the bower.json file, I thought it supported swagger-ui 2.0.24, is that not the case?

felipecao avatar Apr 20 '15 16:04 felipecao

Actually Swagger Spec 2.0 supports custom fields that are prefixed with x-. Look at this.

Unfortunately, we can't do that until Swaggydoc moves to Swagger 2.0 spec. That is quite a bit of work.

The UI does support 2.0 spec, but the json that is being generated right now is based on the 1.2 spec. I hope to get the 2.0 spec implemented as and when time permits, but can't offer a timeline on it. When I merged the previous PR, I thought that it was adding the constraints supported by swagger until i realized it wasn't.

rahulsom avatar Apr 20 '15 23:04 rahulsom