Azure / Azure/data-api-builder
[Bug]: Kiota generation is weird because of the OpenAPI scheme
- Vorherrschende Sprache
- C#
- Sterne
- 1.5k
- Forks
- 370
- Ø Merge
- 3 T. 22 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
### What happened?
For a simple orders table, I get this path in the OpenAPI document
```json
"/Order": {
"get": {
"tags": [
"Order"
],
"description": "Returns entities.",
"parameters": [
{
"name": "X-MS-API-ROLE",
"in": "header",
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
},
{
"name": "$select",
"in": "query",
"description": "A comma separated list of fields to return in the response.",
"schema": {
"type": "string"
}
},
{
"name": "$filter",
"in": "query",
"description": "An OData expression (an expression that returns a boolean value) using the entity's fields to retrieve a subset of the results.",
"schema": {
"type": "string"
}
},
{
"name": "$orderby",
"in": "query",
"description": "Uses a comma-separated list of expressions to sort response items. Add 'desc' for descending order, otherwise it's ascending by default.",
"schema": {
"type": "string"
}
},
{
"name": "$first",
"in": "query",
"description": "An integer value that specifies the number of items to return. Default is 100.",
"schema": {
"type": "integer"
}
},
{
"name": "$after",
"in": "query",
"description": "An opaque string that specifies the cursor position after which results should be returned.",
"schema": {
"type": "string"
}
}
],
"responses": {
"400": {
"description": "BadRequest"
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "NotFound"
},
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Order"
}
},
"nextLink": {
"type": "string"
}
}
}
}
}
}
}
},
"post": {
"tags": [
"Order"
],
"description": "Create entity.",
"parameters": [
{
"name": "X-MS-API-ROLE",
"in": "header",
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Order_NoAutoPK"
}
}
},
"required": true
},
"responses": {
"400": {
"description": "BadRequest"
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "NotFound"
},
"201": {
"description": "Created",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Order"
}
}
}
}
}
}
},
"409": {
"description": "Conflict"
}
}
}
}
```
Then I run Kiota in the document and I get the following
```cs
[Obsolete("This method is obsolete. Use GetAsOrderGetResponseAsync instead.")]
public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { /*stuff*/}
public async Task GetAsOrderGetResponseAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { /* stuff */}
```
From what I understood, this is a problem on the generated OpenAPI Specification that is not enough typed (the object should be an explicit object like "OrderCollection"
```json
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Order"
}
},
"nextLink": {
"type": "string"
}
}
}
}
}
}
```
### Version
1.6.77
### What database are you using?
Azure SQL
### What hosting model are you using?
Custom Docker host
### Which API approach are you accessing DAB through?
REST
### Relevant log output
```Text
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Beitragsleitfaden
Rechercherichtung
Reproduziere das Problem mit dem bereitgestellten OpenAPI-Antwortschema und Kiota 1.6.77 und verfolge anschließend die generierten C#-Antworttypen sowie die Quelle, die diese OpenAPI-Operation erstellt. Vergleiche die generierten Überladungen mit dem vorgeschlagenen expliziten Collection-Schema; abgeschlossen ist die Arbeit, wenn die Antwort durch das vorgesehenen typisierten Modell dargestellt wird und nicht mehr über die veraltete doppelte Methode verfügt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, openapi
- Bereich
- api, backend-api-design
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100