I tried generating a C# Winx64 Client from API located at https://developer.allegro.pl/swagger.yaml using NSwag GUI. No matter which generation mode I choose, I always get code which references FileResponse in one of the methods but there's no FileResponse class generated in the output. The offending API method /sale/dispute-attachments/{attachmentId} is described as returning type */*.
Is this related to form data?
I'm not sure how I should respond to this. The API is provided by third party, it does not designate usage case limits, my use case is backend application and the problem is with generating client from Swagger YAML that I am using to access this API.
Here's the excerpt generating FileResponse reference:
paths:
'/sale/dispute-attachments/{attachmentId}':
put:
tags:
- Disputes
summary: "Upload a dispute message attachment"
description: >-
Upload a dispute message attachment.
This operation should be used after creating an attachment declaration with *POST /sale/dispute-attachments*
**Important!** You can find the URL address to upload the file to our server in the *Location* response header of *POST /sale/dispute-attachments*.
The URL is unique and one-time. As its format may change in time, you should always use the address from the header.
Do not compose the address on your own.
operationId: uploadDisputeAttachmentUsingPUT
parameters:
- name: attachmentId
in: path
required: true
description: Attachment identifier.
schema:
type: string
format: uuid
servers:
- url: https://upload.{environment}
variables:
environment:
default: allegro.pl
enum:
- allegro.pl
- allegro.pl.allegrosandbox.pl
responses:
'201':
description: File uploaded correctly
'400':
description: Syntactically incorrect request
'401':
description: Invalid or missing bearer token
'413':
description: File is too big
'415':
description: Unsupported media type
requestBody:
required: true
content:
image/png:
schema:
type: string
format: binary
description: File in a binary format
image/gif:
schema:
type: string
format: binary
description: File in a binary format
image/bmp:
schema:
type: string
format: binary
description: File in a binary format
image/tiff:
schema:
type: string
format: binary
description: File in a binary format
image/jpeg:
schema:
type: string
format: binary
description: File in a binary format
application/pdf:
schema:
type: string
format: binary
description: File in a binary format
get:
tags:
- Disputes
summary: "Get an attachment"
description: >-
Use this resource to get an attachment. <a href="../../news/2018-09-18-dyskusje/#GetAttach" target="_blank">Read more</a>.
operationId: getAttachmentUsingGET
parameters:
- name: attachmentId
in: path
description: Attachment identifier.
required: true
schema:
type: string
format: uuid
responses:
'200':
description: OK
content:
'*/*':
schema:
type: string
format: binary
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
NSwag config
{
"runtime": "WinX64",
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"json": "...",
"url": "https://developer.allegro.pl/swagger.yaml",
"output": null
}
},
"codeGenerators": {
"openApiToCSharpClient": {
"clientBaseClass": "BaseAllegroClient",
"configurationClass": null,
"generateClientClasses": true,
"generateClientInterfaces": false,
"clientBaseInterface": null,
"injectHttpClient": true,
"disposeHttpClient": true,
"protectedMethods": [],
"generateExceptionClasses": true,
"exceptionClass": "{controller}ApiException",
"wrapDtoExceptions": true,
"useHttpClientCreationMethod": false,
"httpClientType": "System.Net.Http.HttpClient",
"useHttpRequestMessageCreationMethod": true,
"useBaseUrl": false,
"generateBaseUrlProperty": true,
"generateSyncMethods": false,
"exposeJsonSerializerSettings": true,
"clientClassAccessModifier": "public",
"typeAccessModifier": "public",
"generateContractsOutput": false,
"contractsNamespace": null,
"contractsOutputFilePath": null,
"parameterDateTimeFormat": "s",
"parameterDateFormat": "yyyy-MM-dd",
"generateUpdateJsonSerializerSettingsMethod": true,
"useRequestAndResponseSerializationSettings": false,
"serializeTypeInformation": false,
"queryNullValue": "",
"className": "Allegro{controller}Client",
"operationGenerationMode": "SingleClientFromOperationId",
"additionalNamespaceUsages": [],
"additionalContractNamespaceUsages": [],
"generateOptionalParameters": true,
"generateJsonMethods": false,
"enforceFlagEnums": false,
"parameterArrayType": "System.Collections.Generic.IEnumerable",
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
"responseArrayType": "System.Collections.Generic.ICollection",
"responseDictionaryType": "System.Collections.Generic.IDictionary",
"wrapResponses": true,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "{controller}Response",
"namespace": "Allegro_Payout.Clients",
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTimeOffset",
"jsonConverters": null,
"anyType": "object",
"dateTimeType": "System.DateTimeOffset",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.ICollection",
"arrayInstanceType": "System.Collections.ObjectModel.Collection",
"dictionaryType": "System.Collections.Generic.IDictionary",
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
"arrayBaseType": "System.Collections.ObjectModel.Collection",
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
"classStyle": "Poco",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateImmutableArrayProperties": true,
"generateImmutableDictionaryProperties": true,
"jsonSerializerSettingsTransformationMethod": null,
"inlineNamedArrays": false,
"inlineNamedDictionaries": false,
"inlineNamedTuples": true,
"inlineNamedAny": false,
"generateDtoTypes": true,
"generateOptionalPropertiesAsNullable": true,
"templateDirectory": null,
"typeNameGeneratorType": null,
"propertyNameGeneratorType": null,
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "AllegroClient.cs"
}
}
}
Method generated from above request:
public async System.Threading.Tasks.Task<FileResponse> GetAttachmentUsingGETAsync(System.Guid attachmentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
I encountered the same error, but for Typescript client
Most helpful comment
I encountered the same error, but for Typescript client