swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.96k stars 6.04k forks source link

Delete query array fields #8439

Open albertotn opened 6 years ago

albertotn commented 6 years ago

Q&A (please complete the following information)

Content & configuration

If I generate server with java-resteasy and client with typescript-angular, when client call server the working way to delete a resource with list of ids is:

curl -X DELETE "https://localhost:8080/rest/test/?idCampi=1&idCampi=2" -H "accept: application/json"

but from swagger-ui the generated call is

curl -X DELETE "https://localhost:8080/rest/test/?idCampi=1,2" -H "accept: application/json"

that is not working with java-resteasy as server and typescript-angular as client.

Example Swagger/OpenAPI definition:

swagger: "2.0"
info:
  version: "1.0"
  title: "TEST"  
basePath: "/rest"
host: localhost:8080
paths: 
  /test/:
    delete:
      produces:
      - "application/json"  
      parameters:
       - name: "id"
         in: query
         description: "array of id"
         required: true
         type: array
         items: 
           type: "integer"
           format: "int64"
      responses:
        200:
          description: "test response"
          schema:
            type: "string"

Swagger-UI configuration options:

no config

Describe the bug you're encountering

From swagger-ui is not possible to delete a list of resources using array of element, because generated querystring is not generated and parsed correctly from java and angular.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor.swagger.io
  2. import provided yaml
  3. generate resteasy server, extract and run mvn install, then mvn tomcat:run
  4. run provided curl on localhost, changing server context

Expected behavior

I expect the same behaviour from swagger-ui and generated client and server

Screenshots

no screenshoot

Additional context or thoughts

This issue is a folloup from https://github.com/swagger-api/swagger-ui/issues/4736

hkosova commented 6 years ago

This may (or may not) be the same issue as #2961.

albertotn commented 6 years ago

I've found as workaround to specify for every array in input collectionFormat: multi

With this parameter, if found that java jaxrs generator and angular typescript generator work correctly on the parameter.

Angular-ui side is still not working.

My 2 cents: from my point of view not only swagger-ui and swagger-codegen should be aligne on default to use, but when user desig a swagger file with a parameter, must use the same format.

Another question: there is a way to have a default value for collectionFormat or I must specify it on every array ?