microsoft / microsoft/typespec

openapi3 - model extends Array generates invalid schema

Open
#7,519 0 comments 1 reaction 1 assignee Assigned to @Copilot View on GitHub
bug emitter:openapi3 triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

[Playground link](https://typespec.io/playground/?c=bW9kZWwgQSBleHRlbmRzIEFycmF5PGludDMyPiB7fQ0KDQrGI0IgadMe&e=%40typespec%2Fopenapi3&options=%7B%7D)

When a TypeSpec model extends an array, the generated Open API schema is invalid. The schema has `type: object`, while the `allOf` subschema has `type: array`. These contradict.

__Example TypeSpec:__
```tsp
model A extends Array {}

model B is Array {}
```

__Expected Open API Schemas:__
```yml
components:
schemas:
A:
type: array
items:
type: integer
format: int32
B:
type: array
items:
type: integer
format: int32
```

__Actual Open API Schemas:__
```yml
components:
schemas:
A:
type: object
allOf:
- type: array
items:
type: integer
format: int32
B:
type: array
items:
type: integer
format: int32
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.