Skip to content

[TT-16408] add full exclusive maximum and exclusive minimum support#10

Merged
pvormste merged 5 commits intomasterfrom
feat/TT-16408/add-full-exclusiveMaximum-and-exclusiveMinimum-support
Feb 11, 2026
Merged

[TT-16408] add full exclusive maximum and exclusive minimum support#10
pvormste merged 5 commits intomasterfrom
feat/TT-16408/add-full-exclusiveMaximum-and-exclusiveMinimum-support

Conversation

@pvormste
Copy link

@pvormste pvormste commented Feb 5, 2026

This pull request enhances support for OpenAPI Specification (OAS) 3.1's handling of exclusiveMinimum and exclusiveMaximum by allowing these schema properties to be represented as either booleans (OAS 3.0 style) or numeric values (OAS 3.1 style). The changes update the internal schema representation, conversion logic, validation routines, and add new test data to ensure correct handling of both OAS 3.0 and OAS 3.1 forms.

Schema Representation and Serialization:

  • Refactored the Schema struct in openapi3/schema.go to store exclusiveMinimum and exclusiveMaximum as pointers, allowing for both boolean (ExclusiveMinBool, ExclusiveMaxBool) and numeric (ExclusiveMin, ExclusiveMax) forms. Serialization and deserialization logic was updated to handle both OAS 3.0 and 3.1 representations. [1] [2] [3] [4] [5] [6] [7] [8]

Schema Validation Logic:

  • Updated the schema validation logic to correctly validate numbers using either the boolean or numeric forms of exclusiveMinimum and exclusiveMaximum, ensuring compliance with both OAS 3.0 and OAS 3.1. [1] [2] [3]

OpenAPI 2.0/3.0/3.1 Conversion:

  • Modified conversion functions between OpenAPI 2.0 and 3.x to map exclusiveMinimum and exclusiveMaximum appropriately between boolean and numeric forms, preserving the correct semantics during conversion. [1] [2] [3] [4] [5] [6] [7] [8]

Testing Improvements:

  • Updated and expanded tests to cover both boolean and numeric forms of exclusiveMinimum and exclusiveMaximum, including a new helper for boolean pointers and new test data for OAS 3.1. [1] [2] [3] [4]

API Enhancements:

  • Added new builder methods to the Schema type for setting both boolean and numeric forms of exclusiveMinimum and exclusiveMaximum.

These changes ensure robust support for both OAS 3.0 and 3.1 schema validation and conversion, and improve the flexibility and correctness of the OpenAPI tooling.

Comment on lines +890 to +895
if schema.Value.ExclusiveMinBool != nil {
param.ExclusiveMin = *schema.Value.ExclusiveMinBool
}
if schema.Value.ExclusiveMaxBool != nil {
param.ExclusiveMax = *schema.Value.ExclusiveMaxBool
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this condition logic we'll convert values only from v3.0 version and omit values from v3.1. Is it expect? Otherwise we could adjust this conditions to include the next logic:

	if schema.Value.ExclusiveMin != nil {
		v2Schema.ExclusiveMin = true
		v2Schema.Min = schema.Value.ExclusiveMin
	} else if schema.Value.ExclusiveMinBool != nil {
		v2Schema.ExclusiveMin = *schema.Value.ExclusiveMinBool
	}

	if schema.Value.ExclusiveMax != nil {
		v2Schema.ExclusiveMax = true
		v2Schema.Max = schema.Value.ExclusiveMax
	} else if schema.Value.ExclusiveMaxBool != nil {
		v2Schema.ExclusiveMax = *schema.Value.ExclusiveMaxBool
	}

I've tested this on next test:

func TestConvV3SchemaRefToV2(t *testing.T) {
	v3Schema := &openapi3.Schema{
		Type:         &openapi3.Types{"number"},
		ExclusiveMin: openapi3.Ptr(5.0),
		ExclusiveMax: openapi3.Ptr(100.0),
	}

	v2Schema, _ := FromV3SchemaRef(&openapi3.SchemaRef{Value: v3Schema}, nil)

	require.NotNil(t, v2Schema.Value.Min)
	require.Equal(t, 5.0, *v2Schema.Value.Min)
	require.True(t, v2Schema.Value.ExclusiveMin)

	require.NotNil(t, v2Schema.Value.Max)
	require.Equal(t, 100.0, *v2Schema.Value.Max)
	require.True(t, v2Schema.Value.ExclusiveMax)
}

@pvormste pvormste merged commit 0004a83 into master Feb 11, 2026
2 checks passed
@pvormste pvormste deleted the feat/TT-16408/add-full-exclusiveMaximum-and-exclusiveMinimum-support branch February 11, 2026 10:31
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