Skip to content

Conversation

BentEngbers
Copy link

@BentEngbers BentEngbers commented Aug 21, 2025

This minor change to how the parent of a ONE OF element is rendered makes the number of braces match the json format (see example in the comment below)

Checks from the contributing guide:

  • yarn build does not emit any errors
  • the ./dist folder is empty

@BentEngbers BentEngbers changed the title Do not show braces when the child is a OneOf Fix: Do not show braces when the child is a OneOf Aug 21, 2025
@BentEngbers BentEngbers changed the title Fix: Do not show braces when the child is a OneOf fix: Do not show braces when the child is a OneOf Aug 21, 2025
@BentEngbers
Copy link
Author

BentEngbers commented Aug 21, 2025

Example

Consider the following spec.yaml:

openapi: 3.1.0
info:
  title: Simple API
  version: 1.0.0
  description: API with various nullable property examples
paths:
  /items:
    post:
      operationId: test
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                # Polymorphism and Null
                payment_method:
                  description: Can be a credit card, bank account, or null if no payment method is on file.
                  oneOf:
                    - type: object
                      properties:
                        card_number:
                          type: string
                    - type: object
                      properties:
                        bank_account:
                          type: string
                    - type: "null"
                # Object with Nullable Keys
                address:
                  description: An object representing an address where some fields can be explicitly null.
                  type:
                    - object
                    - "null"
                  properties:
                    street:
                      type: string
                    city:
                      type: string
                    postal_code:
                      type: string
                    country:
                      type: string
      responses:
        "200":
          description: OK

This used to render like this:
image

Note that for payment_method, the current schema could be interpreted as invalid json:

  "payment_method": {{
    "card_number": "1234"
  }}

The intended structure is:

  "payment_method": {
    "card_number": "1234"
  }

After this change, the extra braces are removed (for example, the { after the key payment_method):
image

@BentEngbers BentEngbers marked this pull request as ready for review August 21, 2025 14:47
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