Skip to content

v2: Top-level tags property incorrectly serialized in document writing #1991

Closed
@captainsafia

Description

@captainsafia

In 2.0.0-preview2, it appears that the tags property in the OpenAPI document isn't serialized correctly as a list of objects. For example, the following code:

using System;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Writers;
using System.IO;
using System.Globalization;

var document = new OpenApiDocument();

document.Tags = [new OpenApiTag { Name = "test" }];

var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture);
var writer = new OpenApiJsonWriter(outputStringWriter);
document.SerializeAsV2(writer);
Console.WriteLine(outputStringWriter.ToString());

Produces the following document:

{
  "swagger": "2.0",
  "info": { },
  "paths": { },
  "tags": [
    "test"
  ]
}

Which in turn cannot be loaded by the serialization APIs without errors. This happens across all OpenAPI versions (SerializeAsV3, SerializeAsV31).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions