Skip to content

Empty property removed when serializing #2087

Open
@desmarest

Description

@desmarest

Describe the bug
Empty properties are removed when serializing.

Repro steps

            var openApiDocument = new OpenApiDocument
            {
                Components = new OpenApiComponents
                {
                    Schemas = new Dictionary<string, OpenApiSchema>
                    {
                        ["Object"] = new OpenApiSchema
                        {
                            Type = "object",
                            Properties = new Dictionary<string, OpenApiSchema>()
                        }
                    }
                }
            };

            var test = JObject.Parse(openApiDocument.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0));
            Console.WriteLine(test);

Expected result

{
  "swagger": "2.0",
  "info": {},
  "paths": {},
  "definitions": {
    "Object": {
      "type": "object"
      "properties": {}
    }
  }
}

Actual result

{
  "swagger": "2.0",
  "info": {},
  "paths": {},
  "definitions": {
    "Object": {
      "type": "object"
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-discussionAn issue that requires more discussion internally before resolving

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions