Skip to content

Empty collections for default values are omitted during serialization #2555

Description

@baywet

Describe the bug
Using v2.X, whenever a default value is an empty collection/array, it's ignored during serialization.
While this kind of behaviour might be ok for structural properties/collections defined in the specification (since it might be semantically equivalent), it's not for the default values.

OpenApi File To Reproduce

openapi: 3.1.0info:
title: (title)version: 0.0.0paths: {}components:
schemas:
Bar:
type: objectrequired:
- fooproperties:
foo:
type: arrayitems:
type: stringdefault: []

(parsing and serializing back results in the default value disappearing)

Expected behavior
The default empty collection to be present in the serialized representation.

I intend to follow up with a pull request for this issue.

Screenshots/Code Snippets
If applicable, add screenshots of the stack trace or a code snippet to help explain your problem.
If applicable, add a link to your project

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions