Skip to content

fix: #1905 handle oneOf in nested allOf schemas#1904

Open
matgr1 wants to merge 5 commits into
oapi-codegen:mainfrom
matgr1:fix-one-of-nesting
Open

fix: #1905 handle oneOf in nested allOf schemas#1904
matgr1 wants to merge 5 commits into
oapi-codegen:mainfrom
matgr1:fix-one-of-nesting

Conversation

@matgr1

@matgr1 matgr1 commented Feb 14, 2025

Copy link
Copy Markdown

the main purpose of this PR is to fix the situation where oneOf gets lost in deeply nested allOf schemas, for example:

{
  "allOf": [
    {
      "allOf": [
        {
          "oneOf": [
            { "properties": { "a_foo_one_of_0": { "type": "string" } } },
            { "properties": { "a_foo_one_of_1": { "type": "string" } } }
          ]
        }
      ]
    },
    { "properties": { "a_foo": { "type": "string" } } }
  ]
}

see added comments in merge_schemas.go for explanation

other fixes/improvements:

  • includes anyOf as well as oneOf during schema merge
  • improves duplicate typename log message (includes path and detailed diff)
  • removes unused parameter in mergeOpenapiSchemas

@matgr1
matgr1 requested a review from a team as a code owner February 14, 2025 18:13
@matgr1
matgr1 marked this pull request as draft February 14, 2025 18:13
@matgr1
matgr1 force-pushed the fix-one-of-nesting branch from 18f41f2 to 040c7aa Compare February 14, 2025 18:52
@matgr1
matgr1 force-pushed the fix-one-of-nesting branch from 040c7aa to eb82ae9 Compare February 14, 2025 19:02
@matgr1 matgr1 changed the title fix: fully flatten allOf; handle oneOf/anyOf more correctly fix: #1905 fully flatten allOf; handle oneOf/anyOf more correctly Feb 14, 2025
@matgr1 matgr1 changed the title fix: #1905 fully flatten allOf; handle oneOf/anyOf more correctly fix: #1905 handle oneOf in nested allOf schemas Feb 14, 2025
@matgr1
matgr1 marked this pull request as ready for review February 14, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant