Comments (5)
No and probably will not be. As that would change the schemas fundamentally and change the original meaning of the schema.
However you can do this yourself if you want that custom behaviour.
const result = merge(
{
type: "string",
allOf: [
{
type: "number",
},
],
},
{
resolvers: {
type(values, path, mergeSchemas, options) {
return values;
},
},
}
);
console.log(JSON.stringify(result, null, 2));
```
```json
{
"type": [
"string",
"number"
]
}
```
You probably also want to remove any duplicates on the values.
from json-schema-merge-allof.
from json-schema-merge-allof.
Yes multiple types are allowed and supported.
It is just that this schema will always fail validation. One schema says it must be string, another that it must be number.
{
type: "string",
allOf: [
{
type: "number",
},
],
}
This library does not combine schemas and allow all variants. It preserves the validation of how it was before.
Either both of the schemas should have "type": ["string", "number"]
or just one of them. That way it would work as expected.
from json-schema-merge-allof.
from json-schema-merge-allof.
But of course if you have control and know the "risks" then this is a perfect use case for the custom resolver.
The only other variant of this that is officially supported is to ignore the additionalProperties: false
during the merge phase. As two schemas with one of them having that set will basically never allow anything outside the schema it is in. And that is not very useful when composing multiple schemas.
from json-schema-merge-allof.
Related Issues (19)
- Allow Different Resolver Functionality based on Parent Field HOT 4
- What is version 0.7.0? HOT 5
- Could you update the releases and package.json?
- Package does not get transpiled when used with webpack/babel HOT 4
- Merging examples
- Need a config option to allow not merging certain `allOf` schemas
- Process schemas nested inside another document (like in OpenAPI schema) HOT 3
- Porting to typescript
- how to keep the local references? HOT 1
- In what way should the order of items in an allOf matter for descriptions? HOT 1
- Doesn't work with schemas that have cyclical references HOT 2
- Is this library still maintained? HOT 2
- Required resolver not being executed
- Merging compatible Integers and Numbers
- Confirmation of browser support HOT 1
- Unit tests with patterns HOT 7
- Merging formats
- Impossible to write resolver that ignores values coming from allOf items HOT 2
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 json-schema-merge-allof.