Skip to content

embedded objects in a schema are not appearing in the swagger Model Schema #63

@robblovell

Description

@robblovell

In both of the ways of specifying an embedded object below, the field in the parent of the embedded object does not appear in the Model Schema:

Schema = require('mongoose').Schema
case1 = new Schema(
  {
    field1: String
    field2: String
  }
)
case2 = {
  field3: String
  field4: String
}
root = {
  case1: case1
  case2: case2
}
object = new Schema(root, {strict: false})

Resulting Model Schema is missing case1 and doesn't show case2 the way I would expect.

{
  "case2.field3": "string",
  "case2.field4": "string",
  "_id": "string"
}

Expected:

{
  "case1": {"field1": "string", "field2": "string"}
  "case2": {"field3": "string", "field4": "string"}
  "_id": "string"
}

Note, that if the field is an array, it does show up correctly:

{
  "case3": [{"field5": "string", "field6": "string"}]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions