Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
helio-durable opened this issue Nov 12, 2021 · 0 comments
Open

Comments

@helio-durable
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant