-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK Generation does not handle endpoints with hyphen (-) characters #3599
Comments
Hi @barrettnichting The following unit test pases. [Fact]
public async Task HandlesSpecialCharactersInPathSegment()
{
var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
await File.WriteAllTextAsync(tempFilePath, @$"openapi: 3.0.1
info:
title: OData Service for namespace microsoft.graph
description: This OData service is located at https://graph.microsoft.com/v1.0
version: 1.0.1
servers:
- url: https://api.funtranslations.com
paths:
/my-api:
get:
responses:
'200':
content:
application/json:
schema:
type: string");
var mockLogger = new Mock<ILogger<KiotaBuilder>>();
var builder = new KiotaBuilder(mockLogger.Object, new GenerationConfiguration { ClientClassName = "Graph", OpenAPIFilePath = "https://api.apis.guru/v2/specs/funtranslations.com/starwars/2.3/swagger.json" }, _httpClient);
await using var fs = new FileStream(tempFilePath, FileMode.Open);
var document = await builder.CreateOpenApiDocumentAsync(fs);
var node = builder.CreateUriSpace(document);
builder.SetApiRootUrl();
var codeModel = builder.CreateSourceModel(node);
var rootNS = codeModel.FindNamespaceByName("ApiSdk");
Assert.NotNull(rootNS);
Assert.Null(codeModel.FindNamespaceByName("ApiSdk.my-api"));
Assert.NotNull(codeModel.FindNamespaceByName("ApiSdk.MyApi"));
} |
Hi @baywet I am importing my yaml and selecting a single path (deeply nested) that has a hyphen then using "generate api client" Then I am creating a dotnet 7.0 console app. I attempt to run this and get a build error. Various build errors such as: The namespace in my generated model has the hyphen and I believe is the problem. |
Thanks for the additional details. |
@baywet That is correct it is in both, but it looks like the schema is actually the problem. Snippet:
|
Thanks for the additional information, I put together #3628 to address this issue. |
When generating an SDK on an API that contains hyphenated endpoints namespace values are generated with hyphen characters and will not build.
path: /api/v1/my-api
This generates a namespace such as ApiSDK.Models.My-api that is invalid and will not compile.
The text was updated successfully, but these errors were encountered: