-
version v4.34.2 #file1.yaml paths:
/something:
bla: 1
components:
schemas:
Pet: #file1
this-should-not-appear: 123123
NotGenerated: #file1
type: string
#generated.yaml components:
schemas:
Pet: #gen
only-this-field-should-appear: 1
SomethingElse: #gen
x-is-generated: true
type: object
properties:
id:
type: integer
executing either: yq eval-all "(
select(fi == 0).components.schemas
) as \$schemas
| (
select(fi == 1).components.schemas
) as \$generated_schemas
| select(fi == 0)
| .components.schemas = \$generated_schemas *n \$schemas
" file1.yaml generated.yaml
#or
yq eval-all "(
select(fi == 0).components
) as \$components
| (
select(fi == 1).components
) as \$generated_components
| select(fi == 0)
| .components = \$generated_components *n \$components
" file1.yaml generated.yaml outputs the following: paths:
/something:
bla: 1
components:
schemas:
Pet: #gen
only-this-field-should-appear: 1
this-should-not-appear: 123123
SomethingElse: #gen
x-is-generated: true
type: object
properties:
id:
type: integer
NotGenerated:
type: string is there a way to prevent merging recursively? i.e. Pet should only have the field |
Beta Was this translation helpful? Give feedback.
Answered by
mikefarah
Feb 9, 2024
Replies: 1 comment 1 reply
-
You can use "+" as a shallow merge:
paths:
/something:
bla: 1
components:
schemas:
Pet: #gen
only-this-field-should-appear: 1
SomethingElse: #gen
x-is-generated: true
type: object
properties:
id:
type: integer |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
danicc097
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use "+" as a shallow merge: