Required Validators On Nested Objects was not working properly#39
Open
simonjoom wants to merge 13 commits into
Open
Required Validators On Nested Objects was not working properly#39simonjoom wants to merge 13 commits into
simonjoom wants to merge 13 commits into
Conversation
added 13 commits
May 13, 2017 19:10
fixed bug for additional-properties with array of items (line 407-410) -> Required Validators On Nested Objects fixed with required on nested object i had a error from mongoose:: /Cannot.*'required'/ As well i could enter any object when i create the validation of schema is not working. See http://mongoosejs.com/docs/validation.html Chapitre: « Required Validators On Nested Objects » The return getSchema isn't a full fledged path , need to use a single nested schema else the user can enter any schema object the validation will pass (mongoose will comporte as a type Mixed. Solution: Fixed properly validation check with nested object process ref should to return a type to a Object mongoose.schema and not a simple javascript object. Added support of array of enum with multiple values (line 257) props[key] = [{type: String, enum: property.items.enum}]; Here a sample of definitions i work with: (you can see required attribute for nested schema latlng and bounds definitions= { latlng: { "type":"object", "required": [ "lat", "lng" ], "properties": { "lat": { "type": "number", "format": "long", "description": "latitude" }, "lng": { "type": "number", "format": "long", "description": "longitude" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, bounds: { "type":"object", "required": [ "_southWest", "_northEast" ], "description": "The boundary object", "properties": { "_southWest": { "$ref": "#/definitions/latlng" }, "_northEast": { "$ref": "#/definitions/latlng" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, boundary: { "type":"object", "required": [ "name", "bounds" ], "properties": { "name": { "type": "string", "description": "name" }, "color": { "type": "string", "description": "color" }, "bounds": { "$ref": "#/definitions/bounds" }, "createdBy": { "type": "string", "description": "createdBy" }, }, "x-swagger-mongoose": { "additional-properties": { "boundaries": { "items": { "x-swagger-mongoose": { "$ref": "#/definitions/boundaryRects" }, }, }, }, "schema-options": { "timestamps": "true" } } } }
with required on nested object i had a error from mongoose:: /Cannot.*'required'/ As well i could enter any object when i create the validation of schema is not working. See http://mongoosejs.com/docs/validation.html Chapitre: « Required Validators On Nested Objects » The return getSchema isn't a full fledged path , need to use a single nested schema else the user can enter any schema object the validation will pass (mongoose will comporte as a type Mixed. Solution: Fixed properly validation check with nested object process ref should to return a type to a Object mongoose.schema and not a simple javascript object. Added support of array of enum with multiple values (line 257) props[key] = [{type: String, enum: property.items.enum}]; fixed bug for additional-properties with array of items (line 407-410) Here a sample of definitions i work with: (you can see required attribute for nested schema latlng and bounds definitions= { latlng: { "type":"object", "required": [ "lat", "lng" ], "properties": { "lat": { "type": "number", "format": "long", "description": "latitude" }, "lng": { "type": "number", "format": "long", "description": "longitude" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, bounds: { "type":"object", "required": [ "_southWest", "_northEast" ], "description": "The boundary object", "properties": { "_southWest": { "$ref": "#/definitions/latlng" }, "_northEast": { "$ref": "#/definitions/latlng" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, boundary: { "type":"object", "required": [ "name", "bounds" ], "properties": { "name": { "type": "string", "description": "name" }, "color": { "type": "string", "description": "color" }, "bounds": { "$ref": "#/definitions/bounds" }, "createdBy": { "type": "string", "description": "createdBy" }, }, "x-swagger-mongoose": { "additional-properties": { "boundaries": { "items": { "x-swagger-mongoose": { "$ref": "#/definitions/boundaryRects" }, }, }, }, "schema-options": { "timestamps": "true" } } } }
with required on nested object i had a error from mongoose:: /Cannot.*'required'/ As well i could enter any object when i create the validation of schema is not working. See http://mongoosejs.com/docs/validation.html Chapitre: « Required Validators On Nested Objects » The return getSchema isn't a full fledged path , need to use a single nested schema else the user can enter any schema object the validation will pass (mongoose will comporte as a type Mixed. Solution: Fixed properly validation check with nested object process ref should to return a type to a Object mongoose.schema and not a simple javascript object. Added support of array of enum with multiple values (line 257) props[key] = [{type: String, enum: property.items.enum}]; fixed bug for additional-properties with array of items (line 407-410) Here a sample of definitions i work with: (you can see required attribute for nested schema latlng and bounds definitions= { latlng: { "type":"object", "required": [ "lat", "lng" ], "properties": { "lat": { "type": "number", "format": "long", "description": "latitude" }, "lng": { "type": "number", "format": "long", "description": "longitude" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, bounds: { "type":"object", "required": [ "_southWest", "_northEast" ], "description": "The boundary object", "properties": { "_southWest": { "$ref": "#/definitions/latlng" }, "_northEast": { "$ref": "#/definitions/latlng" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, boundary: { "type":"object", "required": [ "name", "bounds" ], "properties": { "name": { "type": "string", "description": "name" }, "color": { "type": "string", "description": "color" }, "bounds": { "$ref": "#/definitions/bounds" }, "createdBy": { "type": "string", "description": "createdBy" }, }, "x-swagger-mongoose": { "additional-properties": { "boundaries": { "items": { "x-swagger-mongoose": { "$ref": "#/definitions/boundaryRects" }, }, }, }, "schema-options": { "timestamps": "true" } } } }
with required on nested object i had a error from mongoose:: /Cannot.*'required'/ As well i could enter any object when i create the validation of schema is not working. See http://mongoosejs.com/docs/validation.html Chapitre: « Required Validators On Nested Objects » The return getSchema isn't a full fledged path , need to use a single nested schema else the user can enter any schema object the validation will pass (mongoose will comporte as a type Mixed. Solution: Fixed properly validation check with nested object process ref should to return a type to a Object mongoose.schema and not a simple javascript object. Added support of array of enum with multiple values (line 257) props[key] = [{type: String, enum: property.items.enum}]; fixed bug for additional-properties with array of items (line 407-410) Here a sample of definitions i work with: (you can see required attribute for nested schema latlng and bounds definitions= { latlng: { "type":"object", "required": [ "lat", "lng" ], "properties": { "lat": { "type": "number", "format": "long", "description": "latitude" }, "lng": { "type": "number", "format": "long", "description": "longitude" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, bounds: { "type":"object", "required": [ "_southWest", "_northEast" ], "description": "The boundary object", "properties": { "_southWest": { "$ref": "#/definitions/latlng" }, "_northEast": { "$ref": "#/definitions/latlng" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, boundary: { "type":"object", "required": [ "name", "bounds" ], "properties": { "name": { "type": "string", "description": "name" }, "color": { "type": "string", "description": "color" }, "bounds": { "$ref": "#/definitions/bounds" }, "createdBy": { "type": "string", "description": "createdBy" }, }, "x-swagger-mongoose": { "additional-properties": { "boundaries": { "items": { "x-swagger-mongoose": { "$ref": "#/definitions/boundaryRects" }, }, }, }, "schema-options": { "timestamps": "true" } } } }
with required on nested object i had a error from mongoose:: /Cannot.*'required'/ As well i could enter any object when i create the validation of schema is not working. See http://mongoosejs.com/docs/validation.html Chapitre: « Required Validators On Nested Objects » The return getSchema isn't a full fledged path , need to use a single nested schema else the user can enter any schema object the validation will pass (mongoose will comporte as a type Mixed. Solution: Fixed properly validation check with nested object process ref should to return a type to a Object mongoose.schema and not a simple javascript object. Added support of array of enum with multiple values (line 257) props[key] = [{type: String, enum: property.items.enum}]; fixed bug for additional-properties with array of items (line 407-410) Here a sample of definitions i work with: (you can see required attribute for nested schema latlng and bounds definitions= { latlng: { "type":"object", "required": [ "lat", "lng" ], "properties": { "lat": { "type": "number", "format": "long", "description": "latitude" }, "lng": { "type": "number", "format": "long", "description": "longitude" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, bounds: { "type":"object", "required": [ "_southWest", "_northEast" ], "description": "The boundary object", "properties": { "_southWest": { "$ref": "#/definitions/latlng" }, "_northEast": { "$ref": "#/definitions/latlng" } }, "x-swagger-mongoose": { "schema-options": { "_id": false } } }, boundary: { "type":"object", "required": [ "name", "bounds" ], "properties": { "name": { "type": "string", "description": "name" }, "color": { "type": "string", "description": "color" }, "bounds": { "$ref": "#/definitions/bounds" }, "createdBy": { "type": "string", "description": "createdBy" }, }, "x-swagger-mongoose": { "additional-properties": { "boundaries": { "items": { "x-swagger-mongoose": { "$ref": "#/definitions/boundaryRects" }, }, }, }, "schema-options": { "timestamps": "true" } } } }
Debug in case of unrecognized schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-> Required Validators On Nested Objects fixed
with required on nested object i had a error from mongoose:: /Cannot.*'required'/ As well i could enter any object when i create the validation of schema is not working.
See http://mongoosejs.com/docs/validation.html
Chapitre:
« Required Validators On Nested Objects »
The return getSchema isn't a full fledged path , need to use a single nested schema else the user can enter any schema object the validation will pass (mongoose will comporte as a type Mixed.
Solution:
Fixed properly validation check with nested object process ref should to return a type to a Object mongoose.schema and not a simple javascript object.
there is as well different bug fixed
Was tested with last swagger.