Skip to content

Descriptions are omitted for schema references #393

Closed
@martincostello

Description

@martincostello

If a property of a definition references another defined type via a reference, the description for the property is not written to the schema.

This means that specificity in a document for a description for a type of a property is not serialized to the schema.

This is because if the Reference property is non-null, it is the only property serialized.

https://github.com/Microsoft/OpenAPI.NET/blob/c08eb18391e42555c00297de5530503f3be318a7/src/Microsoft.OpenApi/Models/OpenApiSchema.cs#L254-L258

https://github.com/Microsoft/OpenAPI.NET/blob/c08eb18391e42555c00297de5530503f3be318a7/src/Microsoft.OpenApi/Models/OpenApiSchema.cs#L427-L431

When the schema is serialized, allowable metadata such as the description should still be serialized when a reference is present.

Expected

"definitions": {
  "Foo": {
    "description": "A foo",
    "type": "object",
    "properties": {
      "bar": {
        "$ref": "#/definitions/Bar",
        "description": "A custom Bar"
      }
    }
  },
  "Bar": {
    "description": "A bar",
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      }
    }
  }
}

Actual

"definitions": {
  "Foo": {
    "description": "A foo",
    "type": "object",
    "properties": {
      "bar": {
        "$ref": "#/definitions/Bar"
      }
    }
  },
  "Bar": {
    "description": "A bar",
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      }
    }
  }
}

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