-
Notifications
You must be signed in to change notification settings - Fork 13
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
Requirements get lost when model is made a definition #2
Comments
You reported two problems here. For 1, For 2, you made a mistake. "xxxParentModel": {
"type": "object",
"required": [..., "tenor"],
"properties": {...}
} Tips: if you omit the ref name from period definition, it'll work well. To reuse a mapping definition, you needn't give it a ref name. |
Ok, maybe I'm completely misunderstanding, but if I manually create a primitive definition like I had, and check it in the swagger editor, it is valid, e.g. "Period": {
"type": "string",
"pattern": "^P.*"
} I know I can reuse the definitions in code, but I want to avoid that the json output is cluttered with repeated pattern definitions, hence I want to be able to push it down into the definitions. According to the spec, the Definitions Object exists of Schema Objects, which specifies: So that leaves us with the "myModel": {
"type": " object",
"title": "MyModel",
"required": [
"myPeriod"
],
"properties": {
"myPeriod": {
"$ref": "#/definitions/Period"
},
"otherPeriod": {
"$ref": "#/definitions/Period"
}
}
} |
Well, did I do a wrong mapping? Currently, I mapped a definition to a model directly, then, for a primitive model, the pattern and required were lost, since the ModelImpl hasn't properties to hold them. I'm curious how you did it. Can you show it to me in details? |
I see, looking at the Could that be missing in the Swagger implementation, or do I really misunderstand the specs? |
Just checked the spec. Seems it didn't require that. |
I have a simple case where I want to reuse a definition for a time period:
This gets translated in the following definition:
Also, if I add the required constraint to the field when used in a mapping like so:
field("tenor", period.constraint(required()))
This required field is not reflected in the spec.
The text was updated successfully, but these errors were encountered: