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

fix(json-schema-2020-12-samples): skip anyOf and oneOf while merging schemas #9853

Merged
merged 3 commits into from Apr 23, 2024

Conversation

glowcloud
Copy link
Contributor

Refs #9198

@glowcloud
Copy link
Contributor Author

I'm not sure if we would ever want to keep these keywords while merging. It looks like we're not doing so for json-schema-samples-5 in:

export const mergeJsonSchema = (target, source, config = {}) => {

which is why there was no issue for OpenAPI 3.x.

If we were to keep them, I was thinking of moving the deletion to sampleFromSchemaGeneric, ex. for anyOf in here:

if (Array.isArray(items.anyOf)) {
sampleArray.push(
...items.anyOf.map((i) =>
sampleFromSchemaGeneric(
merge(i, items, config),
config,
undefined,
respectXML
)
)
)

do something like:

const itemsWIthoutAnyOf = { ...items }
delete itemsWithoutAnyOf.anyOf

 sampleArray.push( 
   ...items.anyOf.map((i) => 
     sampleFromSchemaGeneric( 
       merge(i, itemsWithoutAnyOf, config), 
       config, 
       undefined, 
       respectXML 
     ) 
   ) 
 ) 

but it looks like we would need to do that in a few places in that function.

@char0n
Copy link
Member

char0n commented Apr 23, 2024

const { anyOf, ...itemsWithoutanyOf } = items

@char0n
Copy link
Member

char0n commented Apr 23, 2024

We'll go with the suggestion of contectual handling instead of embedding withing the merge function where it technically does't belong.

Copy link
Member

@char0n char0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@char0n char0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

@char0n char0n merged commit f7373a0 into master Apr 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants