Comments (2)
I know there's this section in the docs:
Alternatively JSONSchema can take a function of type (existingSchema: SchemaObject, options: IOptions) => SchemaObject. The return value of this function is then not automatically merged into existing schema (i.e. the one derived from class-validator decorators). Instead you can handle merging yourself in whichever way is preferred, the idea being that removal of existing keywords and other more complex overwrite scenarios can be implemented here.
However I'm a bit lost regarding how to actually use this, if you can help at all. Would be great to have a code example of this functionality in the docs as well.
from class-validator-jsonschema.
The example you posted doesn't contain any inheritance so the problem probably lies somewhere else.
Can you post the exact JSON Schema you're getting in your use case? My guess is that in your example case we end up with a Product
schema of something like
{
"properties": {
"name": {
"$ref": "<ref to LocalizedString schema>",
"description": "The name of the product and its translations."
}
}
}
And since earlier JSON Schema drafts ignore all other than $ref
properties in a reference schema (source), description
gets dropped.
OpenAPI's reference objects likewise cannot be extended with additional properties and any properties added SHALL be ignored.
https://swagger.io/specification/#reference-object
If that's the case, the solution is to either try some of the creative workarounds mentioned here https://stackoverflow.com/questions/33565090/json-schema-property-description-and-ref-usage or to introduce some sort of complex duplication logic into the library. Or we could wait for OpenAPI v3.1.0 which will finally support the latest JSON Schema draft in its entirety 🙂
from class-validator-jsonschema.
Related Issues (20)
- Regression bug validationMetadatasToSchemas v5.0.0 HOT 7
- Mixed array of custom type
- Incorrectly generated schema for subclasses HOT 2
- Don't use refs for nested objects HOT 3
- validationMetadatasToSchemas result missing derived classes HOT 1
- Validation Groups Feature HOT 1
- class-transformer package is missing as npm dependency HOT 1
- How to get jsonschema for only one class ? HOT 10
- Can you convert from JSON back to class? HOT 1
- Regular expression for IS_DATE_STRING is missing escape characters HOT 1
- Typescript build failing HOT 1
- @isEnum "type": "string"
- Reflect.getMetadata is not a function when using @Type nested property type HOT 1
- Support for Fastify or Fastify-Swagger
- Bug with decorator `@Exclude` processing on classes inheritance HOT 1
- Regular expression for IS_DATE_STRING is missing escape characters
- class-transformer version mismatch HOT 1
- Move inherited properties before sub class properties
- Error with latest version of node
- class transformer discriminators
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from class-validator-jsonschema.