Skip to content

Emit required properties and normalize nullable handling for OpenAPI 3.1#165

Open
tom-ioki wants to merge 2 commits into
mainfrom
fix/documentation-required-and-nullable
Open

Emit required properties and normalize nullable handling for OpenAPI 3.1#165
tom-ioki wants to merge 2 commits into
mainfrom
fix/documentation-required-and-nullable

Conversation

@tom-ioki

@tom-ioki tom-ioki commented Jun 17, 2026

Copy link
Copy Markdown

This pull request enhances the OpenAPI schema generation in LightweightSerializer::Documentation by introducing new options for more accurate and standards-compliant output. It adds the ability to emit a required array for non-conditional properties and to optionally omit the deprecated nullable: true keyword, aligning with OpenAPI 3.1 best practices.

OpenAPI schema improvements:

  • Added emit_required and omit_deprecated_nullable parameters to the openapi_schema method, allowing consumers to opt-in to emitting a required array for unconditional properties and to omit the deprecated nullable: true keyword in favor of OpenAPI 3.1-style nullability (type: [x, "null"] or oneOf).
  • Implemented the apply_required! method to populate the required array in the schema, handling both plain and grouped attributes while skipping those gated by a condition. [1] [2]
  • Updated sanitized_documentation_hash and nested_definitions to conditionally remove the nullable: true keyword when the new option is enabled, preventing redundant or deprecated output. [1] [2]

To opt-in do this in you projects swagger_helper.rb (the default for these params is set to false)

LightweightSerializer::Documentation.new(klass).openapi_schema(
  emit_required: true,
  omit_deprecated_nullable: true
)

tom-ioki and others added 2 commits June 17, 2026 16:13
Co-authored-by: Claude <noreply@anthropic.com>
@tom-ioki tom-ioki self-assigned this Jun 17, 2026
@tom-ioki tom-ioki added documentation Improvements or additions to documentation ready for review labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant