NSwag icon indicating copy to clipboard operation
NSwag copied to clipboard

Unhandled exception generating code with openapi2csclient for PagerDuty OpenAPI v3

Open LazaroOnline opened this issue 6 months ago • 2 comments

Running the command to generate the C# client code from the open-API v3 json file from the official PagerDuty url results in an unhandled exception by the nswag command and thus doesn't get to generate any code.

nswag openapi2csclient  /output:PagerDutyClient.cs  /namespace:MyApp /input:https://raw.githubusercontent.com/PagerDuty/api-schema/main/reference/REST/openapiv3.json

Error: System.InvalidOperationException: Could not resolve the path '#/components/responses/OrchestrationPathServiceActiveResponse/content/application~1json/schema'. at NJsonSchema.JsonReferenceResolver.ResolveDocumentReference(Object rootObject, String jsonPath, Type targetType, IContractResolver contractResolver) at NJsonSchema.JsonReferenceResolver.ResolveReferenceAsync(Object rootObject, String jsonPath, Type targetType, IContractResolver contractResolver, Boolean append, CancellationToken cancellationToken) at NJsonSchema.JsonReferenceResolver.ResolveReferenceAsync(Object rootObject, String jsonPath, Type targetType, IContractResolver contractResolver, CancellationToken cancellationToken) at NJsonSchema.JsonSchemaReferenceUtilities.JsonReferenceUpdater.VisitJsonReferenceAsync(IJsonReference reference, String path, String typeNameHint, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, String path, String typeNameHint, ISet1 checkedObjects, Action1 replacer, CancellationToken cancellationToken) at NJsonSchema.Visitors.AsyncJsonReferenceVisitorBase.VisitAsync(Object obj, CancellationToken cancellationToken) at NJsonSchema.JsonSchemaReferenceUtilities.JsonReferenceUpdater.VisitAsync(Object obj, CancellationToken cancellationToken) at NJsonSchema.JsonSchemaReferenceUtilities.UpdateSchemaReferencesAsync(Object rootObject, JsonReferenceResolver referenceResolver, IContractResolver contractResolver, CancellationToken cancellationToken) at NJsonSchema.Infrastructure.JsonSchemaSerialization.FromJsonWithLoaderAsync[T](Func1 loader, SchemaType schemaType, String documentPath, Func2 referenceResolverFactory, IContractResolver contractResolver, CancellationToken cancellationToken) at NSwag.OpenApiDocument.FromJsonAsync(String data, String documentPath, SchemaType expectedSchemaType, Func`2 referenceResolverFactory, CancellationToken cancellationToken) in //src/NSwag.Core/OpenApiDocument.cs:line 204 at NSwag.OpenApiDocument.FromUrlAsync(String url, CancellationToken cancellationToken) in //src/NSwag.Core/OpenApiDocument.cs:line 236 at NSwag.Commands.InputOutputCommandBase.GetInputSwaggerDocument() in //src/NSwag.Commands/Commands/InputOutputCommandBase.cs:line 47 at NSwag.Commands.CodeGeneration.OpenApiToCSharpClientCommand.RunAsync() in //src/NSwag.Commands/Commands/CodeGeneration/OpenApiToCSharpClientCommand.cs:line 281 at NSwag.Commands.CodeGeneration.OpenApiToCSharpClientCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/CodeGeneration/OpenApiToCSharpClientCommand.cs:line 270 at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input) at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input) at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in //src/NSwag.Commands/NSwagCommandProcessor.cs:line 65

Image screenshot: image

Running windows 11, PowerShell 7.4.4,
NSwag version: 14.1.0.0 NJsonSchema version: 11.0.2.0 (Newtonsoft.Json v13.0.0.0)

LazaroOnline avatar Aug 21 '24 05:08 LazaroOnline