Coder Social home page Coder Social logo

Comments (7)

afraz-khan avatar afraz-khan commented on June 16, 2024 2

same here (with class-validator 0.14.0)

 return metadatas.map((meta) => {
app_1             |                      ^
app_1             | 
app_1             | TypeError: metadatas.map is not a function
app_1             |     at populateMetadatasWithConstraints (.../node_modules/class-validator-jsonschema/build/index.js:60:22)
app_1             |     at getMetadatasFromStorage (/(.../node_modules/class-validator-jsonschema/build/index.js:56:12)
app_1             |     at validationMetadatasToSchemas ((.../node_modules/class-validator-jsonschema/build/index.js:15:23

@mcankudis I upgraded class-validator-jsonschema to 5.0.0 but still finding this issue.

from class-validator-jsonschema.

mcankudis avatar mcankudis commented on June 16, 2024

Got a similar error on version 3.1.1 after upgrading the class-validator from 0.13.2 to 0.14. Upgraded class-validator-jsonschema to 5.0.0 and things started working again. If you haven't done so yet, try upgrading the class-validator, maybe that helps.

The error for reference:

TypeError: metadatas.map is not a function
    at populateMetadatasWithConstraints (<my_path>/node_modules/class-validator-jsonschema/src/index.ts:141:20)
    at getMetadatasFromStorage (<my_path>/node_modules/class-validator-jsonschema/src/index.ts:132:10)
    at validationMetadatasToSchemas (<my_path>/node_modules/class-validator-jsonschema/src/index.ts:26:21)

from class-validator-jsonschema.

Luccazx12 avatar Luccazx12 commented on June 16, 2024

same here (with class-validator 0.14.0)

 return metadatas.map((meta) => {
app_1             |                      ^
app_1             | 
app_1             | TypeError: metadatas.map is not a function
app_1             |     at populateMetadatasWithConstraints (.../node_modules/class-validator-jsonschema/build/index.js:60:22)
app_1             |     at getMetadatasFromStorage (/(.../node_modules/class-validator-jsonschema/build/index.js:56:12)
app_1             |     at validationMetadatasToSchemas ((.../node_modules/class-validator-jsonschema/build/index.js:15:23

from class-validator-jsonschema.

Luccazx12 avatar Luccazx12 commented on June 16, 2024

I was able to solve it as follows:

import * as oa from "openapi3-ts";
import { getMetadataArgsStorage, RoutingControllersOptions } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi";
import { validationMetadatasToSchemas } from "class-validator-jsonschema";

const metadataSchemas = validationMetadatasToSchemas();

const storage = getMetadataArgsStorage();
    return routingControllersToSpec(storage, routingControllersOptions, {
      components: {
        schemas: metadataSchemas as Record<string, oa.SchemaObject | oa.ReferenceObject>
      }
});

Library versions

    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "class-validator-jsonschema": "^5.0.0",
    "routing-controllers": "^0.10.1",
    "routing-controllers-openapi": "^4.0.0",

from class-validator-jsonschema.

gregkysenko avatar gregkysenko commented on June 16, 2024

Hello! Any updates for this issue? I am trying to integrate class-validator-jsonschema and It seem I can`t work with nested objects.

from class-validator-jsonschema.

Luccazx12 avatar Luccazx12 commented on June 16, 2024

Hello! Any updates for this issue? I am trying to integrate class-validator-jsonschema and It seem I can`t work with nested objects.

For object arrays too

from class-validator-jsonschema.

osnipezzini avatar osnipezzini commented on June 16, 2024

anyone created some fork with this fix ?

from class-validator-jsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.