swagger-mongoose icon indicating copy to clipboard operation
swagger-mongoose copied to clipboard

Setting object property as "required" causes error

Open nakamorichi opened this issue 8 years ago • 2 comments

Reproducable e.g. by adding property

"test": {
	"type": "object",
	"required": ["x"],
	"properties": {
		"x": { "type": "string" }
	}
}

into Pet definition and "test" into its "required" array in petstore.json and running the tests. This causes following error:

TypeError: Undefined type `undefined` at `test.required`
  Did you try nesting Schemas? You can only nest using refs or arrays.
      at Function.Schema.interpretAsType (node_modules/mongoose/lib/schema.js:674:11)
      at Schema.path (node_modules/mongoose/lib/schema.js:549:29)
      at Schema.add (node_modules/mongoose/lib/schema.js:431:12)
      at Schema.add (node_modules/mongoose/lib/schema.js:420:14)
      at new Schema (node_modules/mongoose/lib/schema.js:102:10)
      at lib/index.js:330:20
      at node_modules/lodash/lodash.js:4944:15
      at baseForOwn (node_modules/lodash/lodash.js:3001:24)
      at node_modules/lodash/lodash.js:4913:18
      at Function.forEach (node_modules/lodash/lodash.js:9359:14)
      at Object.module.exports.compile (lib/index.js:307:5)
      at Context.<anonymous> (test/index.js:408:31)

nakamorichi avatar Mar 06 '17 10:03 nakamorichi

I'm looking into this. This seems to already be supported in some of the test examples

briananderson1222 avatar Mar 08 '17 13:03 briananderson1222

This only occurs on object types, but I've run into this as well.

kellertk avatar Mar 14 '17 03:03 kellertk