Comments (9)
Thank you for providing all the details!
Looking at your spec, we believe that changing additionalProperties: false
in your baseObject to additionalProperties: true
would resolve the issue you are seeing. Would you try this and let us know?
from elements.
Yeah, that will fix it. I am having the same issue only I am not sure what the expected behaviour of allOf
is regarding merging two schemas. Should it ignore additionalProperties
?
from elements.
Hi @brendarearden and @weyert. Sorry for the late response. Indeed it does fix the problem but doesn't give me the desired result which is a new object that combines the properties of the baseObject along with the new properties in the publicBaseGroupObject AND applies the additionalProperties:false
property the new combined set of properties.
I realize this isn't necessarily an elements issue, but does OpenAPI support something like:
# In components/schemas...
baseObject:
type: object
properties:
basePropertyOne:
type: string
basePropertyTwo:
type: int
superObject:
description: >
The object is a superset of the baseObject. It includes everything
that the baseObject has, but also additional parameters.
We want the documentation for this object to show this description as
well as expanding to show the doc strings for the attributes in the
baseObject and extra attributes added here.
We also want the additionalProperties attribute to apply allow all
the properties defined here but cause errors in validation if others
exist
additionalProperties: false
allOf:
- $ref: '#/components/schemas/baseObject'
- type: object
properties:
superPropertyOne:
type: string
Such that a superObject that looks like this:
{
"basePropertyOne": "foo",
"basePropertyTwo": 2,
"superPropertyOne": "bar"
}
Is valid, but one that looks like this:
{
"basePropertyOne": "foo",
"basePropertyTwo": 2,
"superPropertyOne": "bar",
"extraProperty": "baz"
}
Fails validation because of it is an additionalProperty at the "superObject" level?
What I've found is that an additionalProperties: false
setting seems to apply only to the baseObject and actually causes validators to complain about "superPropertyOne" (and also the generated docs don't look good).
from elements.
Yes,I tried to read the JSON schema specification about how allOf merge behaviour should be when additionalProperties
is used. Only I can't figure it out. If you look at the behaviour of Redocly it appears to somehow ignore it?
They do have a page describing allOf
here:
https://redocly.com/docs/resources/all-of/
I do wonder if the validation should differ from what is shown in schema viewer in Elements?
I have the feeling that Redocly always merges the schemas and ignores additionalProperties
-setting when displaying the schemas. A similar functionality can be achieved by setting the ignoreAdditionalProperties
in @stoplight/json-schema-merge-allof
ignoreAdditionalProperties default false
Allows you to combine schema properties even though some schemas have additionalProperties: false This is the most common issue people face when trying to expand schemas using allOf and a limitation of the json schema spec. Be aware though that the schema produced will allow more than the original schema. But this is useful if just want to combine schemas using allOf as if additionalProperties wasn't false during the merge process. The resulting schema will still get additionalProperties set to false.
from elements.
Related Issues (20)
- Make "Omit <fieldname>" checked by default or make it configurable HOT 1
- Show example summary and or descriptions For all Path Item Objects
- "Try It" response preview caches previous response data HOT 5
- toc(oas): malformed path (custom slug) HOT 4
- $.info.license.name Always Add Word "License" HOT 8
- Change Stylesheet on Request Bodies to Improve Curly Brace Readability HOT 3
- Example body missing reference schema attributes HOT 7
- Ability to Disable URL Rewrite HOT 1
- test issue
- Implementing Stoplight Search React Component Results in QueryClient Error HOT 4
- NOT Enums Ignored - Supported by JSON Schema HOT 4
- $refs with relative paths are not properly resolved with async spec loading HOT 6
- Supporting tag groups to better organize the list of endpoints in the left rail HOT 2
- Build failed in node 20 related to tslib HOT 3
- Default boolean schema value is not shown in parameters dropdown HOT 1
- If the same endpoint has both POST and GET methods, only one of them can be accessed HOT 4
- Elements v^8.1.3 => Unfound type declaration with NextJs 14.2.3 HOT 6
- Anchor links from articles not working in Elements Dev Portal
- API with Set-Cookie not working HOT 3
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 elements.