Skip to content

Conversation

@markandrus
Copy link
Contributor

I noticed a bug with allOf on object types. The intersection types were not constructed correctly. I took the same testing approach as #10.

Given the following schema

openapi: 3.0.3
info:
  description: Title
  version: 1.0.0
servers:
  - url: https

components:
  schemas:
    A:
      type: object
      properties:
        a:
          type: string
    AB:
      type: object
      properties:
        b:
          type: string
      allOf:
        - $ref: '#/components/schemas/A'

Before this change

const _components = {
  schemas: {
    A: CloneType(ComponentsSchemasA),
    AB: T.Intersect([CloneType(ComponentsSchemasA)], {
      properties: { b: { type: 'string' } }
    })
  }
}

After this change

const _components = {
  schemas: {
    A: CloneType(ComponentsSchemasA),
    AB: T.Intersect([
      CloneType(ComponentsSchemasA),
      T.Object({
        b: T.Optional(T.String())
      })
    ])
  }
}

@tinchoz49
Copy link
Contributor

This looks great! thank you @markandrus

@tinchoz49 tinchoz49 merged commit fc1b6b7 into geut:main Dec 13, 2024
1 check failed
@markandrus markandrus deleted the fix-compound-types branch December 13, 2024 12:52
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.

2 participants