Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: Kiota generation is weird because of the OpenAPI scheme

Aperta
#3,632 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp, openapi

Direzione di ricerca

Riproduci il problema con lo schema di risposta OpenAPI fornito e Kiota 1.6.77, quindi traccia i tipi di risposta C# generati e il codice sorgente che crea questa operazione OpenAPI. Confronta gli overload generati con lo schema di collection esplicito proposto; il lavoro è completato quando la risposta è rappresentata dal modello tipizzato previsto senza il metodo duplicato obsoleto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug cri triage
What happened?

For a simple orders table, I get this path in the OpenAPI document

"/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

[Obsolete("This method is obsolete. Use GetAsOrderGetResponseAsync instead.")]
public async Task<global::TestSimple.Client.Order.OrderResponse?> GetAsync(Action<RequestConfiguration<global::TestSimple.Client.Order.OrderRequestBuilder.OrderRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) { /*stuff*/}

public async Task<global::TestSimple.Client.Order.OrderGetResponse?> GetAsOrderGetResponseAsync(Action<RequestConfiguration<global::TestSimple.Client.Order.OrderRequestBuilder.OrderRequestBuilderGetQueryParameters>>? 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"

"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

Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
C#
Stelle
1.5k
Fork
371
Merge medio
9g 2h
PR unite (30g)
10

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/data-api-builder

Tutte le issue di Azure/data-api-builder

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.