acacode / acacode/swagger-typescript-api

Circular reference error in type definitions if subclasses appear before baseclass in schema.

Đang mở
#637 1 bình luận 7 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
4.1k
Fork
436
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

We have the following schema components in our swagger.json file:

```
"Gjennomforing_4_3": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/Tvangsprotokoll"
}
],
"additionalProperties": false
},
"Gjennomforing_4_4": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/Tvangsprotokoll"
}
],
"properties": {
"administrertLegemiddel": {
"type": "string",
"nullable": true
},
"administrertDose": {
"type": "string",
"nullable": true
},
"administrasjonsform": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
"Gjennomforing_4_8": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/Tvangsprotokoll"
}
],
"properties": {
"endringUnderGjForing": {
"$ref": "#/components/schemas/VolvenKodeverkValue9272"
},
"beskrivelseAvGjForing": {
"type": "string",
"nullable": true
},
"endretTidspunkt": {
"type": "string",
"format": "date-time",
"nullable": true
}
},
"additionalProperties": false
},
"Tvangsprotokoll": {
"required": [
"$type"
],
"type": "object",
"properties": {
"$type": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"vedtakId": {
"type": "string",
"format": "uuid"
},
"pasientId": {
"type": "string",
"format": "uuid"
},
"fagligAnsvarlig": {
"$ref": "#/components/schemas/Ansvarlig"
},
"startTidspunkt": {
"type": "string",
"format": "date-time",
"nullable": true
},
"avsluttetTidspunkt": {
"type": "string",
"format": "date-time",
"nullable": true
},
"merknad": {
"type": "string",
"nullable": true
},
"lopenummer": {
"type": "integer",
"format": "int32",
"nullable": true
}
},
"additionalProperties": false,
"discriminator": {
"propertyName": "$type",
"mapping": {
"Gjennomforing_4_3": "#/components/schemas/Gjennomforing_4_3",
"Gjennomforing_4_4": "#/components/schemas/Gjennomforing_4_4",
"Gjennomforing_4_8": "#/components/schemas/Gjennomforing_4_8"
}
}
},
```

After running codegen on this schema the output is the following for the 3 subclasses (`Gjennomforing_4_3`, `Gjennomforing_4_4`, `Gjennomforing_4_8`) of Tvangsprotokoll:

![image](https://github.com/acacode/swagger-typescript-api/assets/7986195/060c3456-722f-434f-95fb-e672220dbb26)

Here the subclasses are extending Tvangsprotokoll instead of the BaseTvangsprotokoll class.

We believe this is a bug with the order they are parsed in. As the Base class come after the subclasses in the schema.components list.
Everything worked fine when we renamed Tvangsprotokoll to Gjennomforing

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.