Skip to content

How to define an array of arrays of something with @tsed/schema? #2916

Answered by Romakita
KBroichhausen asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @KBroichhausen

Ts.ED provides a Function API to describe json-schema (look https://tsed.dev/docs/model.html#using-functions).

Here is a working example:

import {Controller} from "@tsed/di";
import {BodyParams} from "@tsed/platform-params";
import {Post, array, Property, Required, Schema, getSpec} from "@tsed/schema";

describe("collection", function() {
  describe("collection of collection of model", () => {
    it("should generate a collection of collection of model", () => {
      class InternalStructure {
        @Required()
        @Property(String)
        public field: string;
      }

      const ArrayOfArrayOfInternalStructure = array()
        .items(array().items(InternalStru…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Romakita
Comment options

@KBroichhausen
Comment options

@Romakita
Comment options

Answer selected by KBroichhausen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants