Skip to content

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

Closed

Description

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).

Activity

  1. MaggieKimani1 commented on Dec 19, 2024

    @MaggieKimani1
    Contributor

    This issue has now been fixed by this PR #1939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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