Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Further improvements to constraints handling #21

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

felipecao
Copy link

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
Copy link
Author

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

Thanks!

@rahulsom
Copy link
Owner

@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.

@felipecao
Copy link
Author

Hi, @rahulsom, thanks for the feedback.

To answer your question, yes, constraints is non standard swagger. Like I said on pull request #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?

@rahulsom
Copy link
Owner

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.

…ce#getModels. I've changed the loop to exit if model was a knownType. The method originally does this check, but only at the end, which made it spend lots of processing time just to discard it in the end. Also, the Queue was allowing repetitions and causing this method to try to process all of the class used by domain objects multiple times, which lead to an infinite loop.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants