Skip to content

feat: Smart example distribution and automatic type broadening (oneOf/anyOf)#1180

Open
squiaios wants to merge 1 commit into
dedoc:mainfrom
squiaios:multiple-examples
Open

feat: Smart example distribution and automatic type broadening (oneOf/anyOf)#1180
squiaios wants to merge 1 commit into
dedoc:mainfrom
squiaios:multiple-examples

Conversation

@squiaios

Copy link
Copy Markdown

Description

This Pull Request improves the handling of multiple examples and union types (anyOf/oneOf)

Usage Example

You no longer need to manually define the union type if your examples cover the expected types:

public function rules() {
    return [
        /**
         * @example {"type": "string", "value": "AZE-123", "summary": "Text Format"}
         * @example {"type": "int", "value": 456, "summary": "Numeric Format"}
         */
        'external_id' => 'alpha_num',
    ];
}

Generated OpenAPI Result:

"external_id": {
  "oneOf": [
    {
      "type": "string",
      "description": "Text Format",
      "example": "AZE-123"
    },
    {
      "type": "integer",
      "description": "Numeric Format",
      "example": 456
    }
  ]
}

@squiaios squiaios force-pushed the multiple-examples branch from 0a2d838 to 2d5a2cf Compare June 11, 2026 12:11
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