tsoa: internal tsoa error: the metadata that was generated should have had nested property schemas since it’s for a nested object,however it did not

Sorting

  • I’m submitting a …

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn’t already been submit

Bug

I get the tsoa error mentioned in the titel. It tells me to open a bug report 😉

What I send to the API: image

What the API has defined:

export type JobDescriptionInternalBlockType =
	| 'intro'
	| string;

export interface IAPIJobDescriptionBlock {
	language: string; // locale or language
	blocks: {
		header?: string;
		internalName?: JobDescriptionInternalBlockType;
		content: string;
	}[];
}

export interface TestInputDTO {
descriptionBlocks?: IAPIJobDescriptionBlock
}

The error happens here: image

Steps to Reproduce

  1. Create an interface with A PUT request like:
@Put('/test')
async test(
    @Body()
    body: TestInputDTO
) {
    // something
    return true;
}
  1. Send request to the api
  2. get error message

Context (Environment)

Version of the library: v2.5.3 Version of NodeJS: v12.6.0

  • Confirm you were using yarn not npm: [ ] <-- i’m usign npm

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

@WoH sorry, I didn’t copy your PR properly, it does indeed generate the subschemas now and the error is gone

"Order": {
    "properties": {
        "date": { "dataType": "datetime", "required": true },
        "delivery": { "dataType": "datetime", "required": true },
        "orderLines": {
               "dataType": "array", 
               "array": {
                  "dataType": "union",
                  "subSchemas": [{ "ref": "OrderLinePurchase" }, { "ref": "OrderLineRent" }, { "ref": "OrderLineService" }, { "ref": "OrderLineFee" }]
               },
               "required": true
          },
     },
    "additionalProperties": false,
}

@simllll the idea for custom transforms sounds fun. Would you mind moving that to a new issue?