-
Notifications
You must be signed in to change notification settings - Fork 12
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
Question : How to hook into schema object generation #20
Comments
I guess what i am looking for is probably ModelBuilderPlugin or may be OperationModelsProvider but dont know where to start.. |
There is already support for certain annotations that influence model generation and properties. All swagger annotations are supported. E.g. ApiModelProperty. In addition where applicable Jackson annotations are supported. Cannot really say without a specific example. Could you perhaps describe what you’re ttrying to do |
@dilipkrish - What I am looking for is, to hook grails constraints into springfox Given the Grails domain class (Model)
From this, I can see, the model has all the information it needs regarding its properties. I am looking for integration point in springfox, that will let me include the above information in model schema. Eg make a field required, default value, min and max values etc. Also, looking for a way to make the author a $ref instead of authorId (Which is what it does currently) I know the grails side, but dont know springfox enough to combine this two things togather. Grails constraints: https://docs.grails.org/3.1.1/ref/Constraints/Usage.html |
So your need to implement the ModelPropertyBuilderPlugin and hook in to the GrailsDomainClass to infer the constraints. Sorry that I’m not intimately familiar with grails but I know it’s accesible if you pull in the right beans. You can dig in further if you’d like and let me know if you have any questions. |
Okay, will try with ModelPropertyBuilder. Given the way grails support is currently implemented, I see that Grails domains are configured with Alternate type rules. Would i need to change any thing there ? Or just ModelPropertyBuilder should be enough. |
Oh that’s right. It is still possible to do it with the plugin I believe but You may need to enhance the rule/convention to support for what your needing to do. In which case u may need to incorporate it as a PR. Im on vacation and don’t have the code in front of me, sorry. Let me know if have any questions I’ll be gals to help. |
@dilipkrish When using AlternateTypePropertyBuilder and AlternateTypeBuilder |
I think that is an enhancement that is in the works in the main springfox library. ModelProperty/ModelPropertyBuilder is missing those properties |
@snimavat When using AlternateTypePropertyBuilder and AlternateTypeBuilder |
You can add a |
@dilipkrish thanks for your quick replay |
I'll have to research this. Do you perhaps have a breaking test? |
I couldnt find any docs so have to ask the question here.
What I am looking for, is to hook into schema object generation.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject
So that we can generate the schema object for domain classes based on mappings and constraints etc. And can specify what fields are required, pattern, description, default value, min max and other constraits etc.
Thanks
The text was updated successfully, but these errors were encountered: