Skip to content

[BUG] monitor insights type widening during TypeSpec conversion #44513

Description

@matthchr

API Spec link

API Spec version

2024-03-11 (may also impact newer versions)

Describe the bug

When the Microsoft.Insights Swagger went through TypeSpec conversion, it seems to have (mistakenly?) produced a widening on one property.

Here's Microsoft.Insights sample before TypeSpec migration for the customVMScrapeConfig field.

        "customVMScrapeConfig": {
          "description": "Custom VM Scrape Config that defines scrape jobs",
          "type": "array",
          "items": {
            "type": "object"
          }
        },

In TypeSpec that was modelled as:

customVMScrapeConfig?: unknown[];

Which renders into OpenAPI as:

        "customVMScrapeConfig": {
          "type": "array",
          "description": "Custom VM Scrape Config that defines scrape jobs",
          "items": {}
        },

Which has a loosened set of restrictions on the array items (allows bool, int, etc, whereas before it had to be an object).

See OAI/OpenAPI-Specification#1388 for a discussion of why "type": "object" and "no type specified" do not mean the same thing.

I think the TypeSpec should have been Record<unknown>[] to preserve the old object restriction.

Expected behavior

        "customVMScrapeConfig": {
          "type": "array",
          "description": "Custom VM Scrape Config that defines scrape jobs",
          "items": {}
        },

items should be of type object.

Actual behavior

items is not of type object.

Reproduction Steps

Read the openAPI specification links above?

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions