When generating the C# client using NSwagStudio or the MSBuild nswag generator it would be beneficial if we can control how query string array parameters are generated.
Currently array parameters are generated for an array query string as follows:
/users:
get:
tags:
- User
summary: List site users
description: Multiple search values can be provided to narrow down the results
operationId: listUsers
parameters:
- name: user_status
in: query
description: Status values that need to be considered for filter
required: false
schema:
title: listUsersParamUserArrayStatus
type: array
items:
type: string
title: listUsersParamUserStatus
enum:
- active
- pending
- imported
- inactive
default: active
?cars[]=Saab&cars[]=Audi (Best way- PHP reads this into an array)
?cars=Saab&cars=Audi (Bad way- PHP will only register last value)
?cars=Saab,Audi (Haven't tried this)
How can we control the array parameter generation in nswag studio, and the NSwag.MSBuild package?
When generating the C# client using NSwagStudio or the MSBuild nswag generator it would be beneficial if we can control how query string array parameters are generated.
Currently array parameters are generated for an array query string as follows:
http://someapi/Users?user_status=active&user_status=pending
However, in PHP the default for these kinds of arrays coming into the API is as follows:
http://someapi/Users?user_status[]=active&user_status[]=pending
Here is an example api YML:
This seems related to https://github.com/RicoSuter/NSwag/issues/1451 and https://github.com/RicoSuter/NSwag/discussions/4377 and https://github.com/RicoSuter/NSwag/issues/3620 and https://github.com/RicoSuter/NSwag/issues/1703 and https://github.com/RicoSuter/NSwag/issues/1842 (array enum issues)
PHP examples to consider from here: https://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string
?cars[]=Saab&cars[]=Audi (Best way- PHP reads this into an array) ?cars=Saab&cars=Audi (Bad way- PHP will only register last value) ?cars=Saab,Audi (Haven't tried this)
How can we control the array parameter generation in nswag studio, and the NSwag.MSBuild package?