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

Sample code is not working #17

Closed
99ACA opened this issue Jul 9, 2019 · 1 comment
Closed

Sample code is not working #17

99ACA opened this issue Jul 9, 2019 · 1 comment

Comments

@99ACA
Copy link

99ACA commented Jul 9, 2019

I am trying to work with the current package without success.
I ran the sample code and I don't get the expect result.
Could you assist me please.

import { getFromContainer, IsOptional, IsString, MaxLength, MetadataStorage } from 'class-validator'
import { validationMetadatasToSchemas } from 'class-validator-jsonschema'

class BlogPost {
@IsString() id: string

@IsOptional()
@maxlength(20, { each: true })
tags: string[]
}

const metadatas = (getFromContainer(MetadataStorage) as any).validationMetadatas
const schemas = validationMetadatasToSchemas(metadatas)
console.log(schemas)

tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "./dist",
"rootDir": "./src",
"sourceMap": true,
"noImplicitAny": true
},
"include": [
"src/**/*.ts",
"package.json"
],
"exclude": [
"node_modules"
]
}

{
"name": "openapi3x1",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "node ./dist/server.js"
},
"author": "zoro",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"class-validator-jsonschema": "^1.3.0",
"config": "^3.1.0",
"express": "^4.17.1",
"lodash": "^4.17.11",
"routing-controllers-openapi": "^1.7.0"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
"@types/config": "0.0.34",
"@types/express": "^4.17.0",
"@types/lodash": "^4.14.135",
"@types/node": "^12.0.12"
}
}

@99ACA
Copy link
Author

99ACA commented Jul 9, 2019

sorry, missing result
image

@99ACA 99ACA changed the title Sample code is working Sample code is not working Jul 9, 2019
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

2 participants