Skip to content

Conversion fails if my model has a property named "description" #36

@helio-durable

Description

@helio-durable

It looks like the algorithm can't differentiate a field named description from the attribute description.

I have a model like this:

//... more properties before here
date: { type: Date, default: Date.now },
    servicesRendered: [{
        _id: false,
        Service: { type: mongoose.Schema.Types.ObjectId, ref: 'Service' },
        description: String,
        quantity: Number,
        price: Number
    }],
    paymentTerms: String,
//more properties after...

the property "description" is not the description of the model but a property with type String.
When converting it to swagger it generates as follows:

"date": {
            "type": "string",
            "format": "date-time"
          },
          "servicesRendered": {
            "type": "array",
            "items": {
              "type": "object",
              "description": function String() { [native code] },
              "properties": {
                "Service": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "price": {
                  "type": "number"
                }
              },
              "required": []
            }
          },
          "paymentTerms": {
            "type": "string"
          },

As you can see, it generates a description "description": function String() { [native code] }, and if failed to load the Swagger UI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions