Expose REST API - Is array type on URL possible?

Hello all 

(Portuguese bellow)


According to the swagger specification (2.0), it is possible to have an array data type passed in the URL as a parameter (GET & DELETE), so I was wondering if (and how) it is possible to expose an API where one of the inputs is of Array data type.

From what I checked and tried to do, I was only able to pass the primitive data types in the URL.


Thank you in advance for any clarification on the matter.

André

-----


Olá

De acordo com a especificação do swagger (2.0), é possível passar um array como parametro no URL de uma API (GET & DELETE). 

Po isso questiono se (e como) é possivel expor uma API onde um dos parametros de entrada seja um array.

Pelo que constatei e tentei fazer, apenas consegui definir os tipos de dados primitivos no URL.


Obrigado,

André

Solution

Hi André,


The only way to that would be to pass the array that you want as text and then process it on your method, you could even pass a JSON  eg ?JSON={colors":["Black","White"]}


Regards,

Diogo Gomes

Solution

Diogo Gomes wrote:

Hi André,


The only way to that would be to pass the array that you want as text and then process it on your method, you could even pass a JSON  eg ?JSON={colors":["Black","White"]}


Regards,

Diogo Gomes


Hi Diogo,

That's exactly what I already did but it's not optimal at all.

If you do that and then read the api specification, then will be misleaded. 

You are able to write whatever you want in the input because it's just a string. On the api provider side they have to plan for whatever input they might get.


I understand this is a constraint of the tool so it would be great if this question is taken as a suggestion for improvement.


Best,

André