fix: null values in examples, example and default (#4339, #4229) by ewaostrowska · Pull Request #5060 · swagger-api/swagger-core (original) (raw)

This pull request enhances how OpenAPI 3.1 Schema objects handle and serialize null and literal "null" values for default, example, and examples fields. The changes ensure correct distinction between a missing field, an explicit null, and the string "null", especially when nullable=true. This improves both the internal model and the generated OpenAPI output, and aligns the code with the OpenAPI 3.1 specification.

Key changes:

Handling of null and "null" values for default and example:

Serialization improvements:

These changes improve the fidelity of OpenAPI schema generation and serialization, especially regarding explicit null handling and the distinction from the literal string "null".

Should fix: #4339 , #4229, #4401