Fix missing using statements in C# union type wrappers by reordering imports#7320
Fix missing using statements in C# union type wrappers by reordering imports#7320gavinbarron merged 10 commits intomainfrom
Conversation
Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
…raversal Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
|
@copilot can you please evaluate if the failure case reported with missing usings applies to any of the other languages that kiota can generate? |
I've evaluated all other language generators (Java, TypeScript, Python, Go, PHP, Ruby, and Dart). They all call Only C# was calling |
Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
|
@copilot please run |
Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
|
@copilot please add an entry to the changelog |
Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
Fix for missing using statements in C# union type wrappers
Changes:
Status:
The fix aligns C# with all other language generators and resolves compilation errors when ImplicitUsings is disabled.
Original prompt
This section details on the original issue you should resolve
<issue_title>Missing usings if "ImplicitUsings" is disabled</issue_title>
<issue_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
See attached sample: the client is created from https://api.twitter.com/2/openapi.json
XKiota.zip
The project does not enable ImplicitUsings (as might happen for older projects).
There are two compilation errors due to missing
usingstatements in classMediaSegmentsExpected behavior
Two usings should be added:
How to reproduce
I used this command to create the client:
Open API description file
https://api.twitter.com/2/openapi.json
Kiota Version
1.29.0
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
No response
Debug output
Click to expand log
```{
"openapi": "3.0.0",
"info": {
"description": "X API v2 available endpoints",
"version": "2.157",
"title": "X API v2",
"termsOfService": "https://developer.x.com/en/developer-terms/agreement-and-policy.html",
"contact": {
"name": "X Developers",
"url": "https://developer.x.com/"
},
"license": {
"name": "X Developer Agreement and Policy",
"url": "https://developer.x.com/en/developer-terms/agreement-and-policy.html"
}
},
"paths": {
"/2/media/upload/{id}/append": {
"post": {
"security": [
{
"OAuth2UserToken": [
"media.write"
]
},
{
"UserToken": []
}
],
"tags": [
"Media"
],
"summary": "Append Media upload",
"description": "Appends data to a Media upload request.",
"externalDocs": {
"url": "https://docs.x.com/x-api/media/media-upload"
},
"operationId": "appendMediaUpload",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The media identifier for the media to perform the append operation.",
"required": true,
"schema": {
"$ref": "#/components/schemas/MediaId"
},
"style": "simple"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MediaUploadAppendRequest"
}
},
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/MediaUploadAppendRequest"
}
}
}
},
"responses": {
"200": {
"description": "The request has succeeded.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MediaUploadAppendResponse"
}
}
}
},
"default": {
"description": "The request has failed.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
},
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
}
}
}
}
},
},
"servers": [
{
"description": "X API",
"url": "https://api.x.com"
}
],
"components": {
"Error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
},
"MediaId": {
"type": "string",
"description": "The unique identifier of this Media.",
"pattern": "^[0-9]{1,19}$",
"example": "1146654567674912769"
},
"MediaUploadAppendRequest": {
"anyOf"...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.