Bug 16699: Support multiple types in primitive definitions
Currently it is not possible to define multiple types for primitive definitions in /definitions/*. If you try to use the following "firstname": { "type": ["string", "null"], "description": "patron's first name" } in definitions.json, online.swagger.io validator will not validate it: {"messages":["attribute definitions.firstname.type is not of type `string`"]} One way to get around this issue is to extend definitions with custom "x-primitives" object, where we will define all reusable primitive definitions. To test: 1. Add the "firstname" example above to definitions.json 2. Run minifySwagger.pl 3. Validate your specification 4. Observe that error with description mentioned above is given 5. Apply patch 6. Repeat step 2 and 3 7. Observe that validation passes Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> My name is Olli-Antti Kivilahti and I approve this commit. We have been using the Swagger2.0-driven REST API on Mojolicious for 1 year now in production and I am certain we have a pretty good idea on how to work with the limitations of Swagger2.0 We participated in the development of the Mojolicious::Plugin::Swagger and know it well. We have made an extension to the plugin to provide full CORS support and have been building all our in-house features on the new REST API. Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com> My name is Johanna Räisä and I approve this commit. We have been using Swagger2.0-driven REST API in production successfully. Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
2aa333fb5f
commit
55a8389bb3
2 changed files with 44 additions and 0 deletions
|
@ -21,5 +21,8 @@
|
|||
},
|
||||
"parameters": {
|
||||
"$ref": "parameters.json"
|
||||
},
|
||||
"x-primitives": {
|
||||
"$ref": "x-primitives.json"
|
||||
}
|
||||
}
|
||||
|
|
41
api/v1/x-primitives.json
Normal file
41
api/v1/x-primitives.json
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"biblionumber": {
|
||||
"type": "string",
|
||||
"description": "internally assigned biblio identifier"
|
||||
},
|
||||
"borrowernumber": {
|
||||
"type": "string",
|
||||
"description": "internally assigned user identifier"
|
||||
},
|
||||
"branchcode": {
|
||||
"type": ["string", "null"],
|
||||
"description": "code of patron's home branch"
|
||||
},
|
||||
"cardnumber": {
|
||||
"type": ["string", "null"],
|
||||
"description": "library assigned user identifier"
|
||||
},
|
||||
"email": {
|
||||
"type": ["string", "null"],
|
||||
"description": "primary email address for patron's primary address"
|
||||
},
|
||||
"firstname": {
|
||||
"type": ["string", "null"],
|
||||
"description": "patron's first name"
|
||||
},
|
||||
"itemnumber": {
|
||||
"type": ["string", "null"],
|
||||
"description": "internally assigned item identifier"
|
||||
},
|
||||
"phone": {
|
||||
"type": ["string", "null"],
|
||||
"description": "primary phone number for patron's primary address"
|
||||
},
|
||||
"reserve_id": {
|
||||
"description": "Internal hold identifier"
|
||||
},
|
||||
"surname": {
|
||||
"type": "string",
|
||||
"description": "patron's last name"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue