-
Notifications
You must be signed in to change notification settings - Fork 304
Description
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Nuget tool
Client library/SDK language
Csharp
Describe the bug
I have a Rest API with the following route: GET /api/contracts/, which returns a list of contracts. There's also one query param type, which is used to filter the contract list.
Kiota will create a ContractsRequestBuilder with the following constructor:
public ContractsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/contracts/{?type*}", pathParameters)
As you can see, type is part of the URL.
Now when you add the route GET /api/contracts/lease/, Kiota will omit all query params for /api/contracts and create the following constructor:
public ContractsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/contracts", pathParameters)
As you can see, type is NOT part of the URL anymore. Even if you can set the query param in code, it won't be added to the request.
Expected behavior
Query params not being omitted in the request.
How to reproduce
Use the OpenAPI description file to generate a client with kiota.
I'm using the following command:
kiota generate -l csharp -d Api.json -c ApiClient -n MyProject.Client -o ./Client --clean-output --backing-store
If you remove the route "/api/contracts/lease/", it will work as expected.
Open API description file
{
"openapi": "3.1.0",
"info": {
"title": "Rest API",
"version": "25.05.15",
"description": ""
},
"paths": {
"/api/contracts/": {
"get": {
"operationId": "rest_backend_api_contract_get_contracts",
"summary": "Get Contracts",
"parameters": [
{
"in": "query",
"name": "type",
"schema": {
"allOf": [
{
"enum": [
"PROPERTY",
"LEASE",
"SUBLEASE",
"EXCHANGE"
],
"title": "ContractType",
"type": "string"
}
]
},
"required": false
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedContractSchema"
}
}
}
}
},
"tags": [
"Vertrag"
]
}
},
"/api/contracts/lease/": {
"get": {
"operationId": "rest_backend_api_contract_get_lease_contracts",
"summary": "Get Lease Contracts",
"parameters": [],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/LeaseContractSchema"
},
"title": "Response",
"type": "array"
}
}
}
}
}
}
}
}
}Kiota Version
1.26.1
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
Create a own route like /api/contracts/all/.
Configuration
No response
Debug output
Click to expand log
```</details>
### Other information
_No response_
Metadata
Metadata
Assignees
Labels
Type
Projects
Status