Skip to content

Conversation

@ShuffleZZZ
Copy link
Member

@ShuffleZZZ ShuffleZZZ commented Dec 30, 2025

Fixes #1544

Changes

  • set bind-type environment variable to true to support schema.type compatibility with new schema.types property.

let me know if there is a better way to setup environment variable in a single place for the project

Context

In new openapi specification versions schema property type is supporting multiple values. Internally, new list property types is used in the java library to support such case. For all type definitions under the new specification, property type is null with types storing the provided values.
To support retrieving a first value of types with type getter, system environment bind-type is used. This allows to treat type definitions under the new specification in the same way as before (supports only a single value).

Remarks

The change is fully compatible with previous specification versions.

Library code reference:

public class Schema<T> {

    public static final String BIND_TYPE_AND_TYPES = "bind-type";
    
    @OpenAPI30
    private String type = null;
    /**
     * @since 2.2.0 (OpenAPI 3.1.0)
     */
    @OpenAPI31
    private Set<String> types;
    
    public String getType() {
        boolean bindTypes = Boolean.valueOf(System.getProperty(BIND_TYPE_AND_TYPES, "false"));
        if (bindTypes && type == null && types != null && types.size() == 1) {
            return types.iterator().next();
        }
        return type;
    }
}

@ShuffleZZZ ShuffleZZZ requested a review from tkrop as a code owner December 30, 2025 11:16
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.

field 'id' has type 'null' (expected type 'string')

1 participant