Skip to content

Typespec openapi3 0.51 generates array as allOf, recursive field, (similar to 2796) #2882

@iw-stefro

Description

@iw-stefro

Hi
Sorry, we're still having a problem with some change between 0.50 and 0.51.
I think this is related/similar to #2796, which is fixed but it seems to be some more corners.
I've tested it with the @next tsp npm packages.

This typespec will in the latest version generate the nested/recursive field as allOf and redocly complains with:

Prerendering docs
Incompatible types in allOf at "#/components/schemas/FilterNode/properties/childNodes": "object" and "array"
allOf: schemas with different types can't be merged
OpenAPI Sampler: found allOf with "array" type. Result may be incorrect

the typespec

import "@typespec/rest";
import "@typespec/openapi3";

using TypeSpec.Http;
using TypeSpec.Rest;

model FilterNode
{
    someField: string;
    childNodes: FilterNode[] | null;         // note e.g. that the ' | null ' here affects, and the post op further down.
}

model QueryParams
{
    filters: FilterNode[] | null;
}

@post op TheSearch(...QueryParams): {}[];

yaml part:

        childNodes:
          type: object
          allOf:
            - type: array
              items:
                $ref: '#/components/schemas/FilterNode'
          nullable: true

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions