0

My method is POST, but it gets data by query parameters. I can't change the logic of the method to retrieve data by body. Is it possible to send a nested array in a query (not in http body, as it usually done in post queries) in this way:

@SWG\Parameter(
    name="find_data",
    in="query",
    type="array",
     required=true,
        SWG\Items(
            SWG\Property(property="service", type="integer", description="Client"),
            SWG\Property(property="tariff", type="integer", description="tariff"),
            SWG\Property(property="connection", type="integer", description="Connection")
        )
)?

I have done the following:

@SWG\Post(path="/tariff/get-by-data",
     tags={"Tariffs"},
     operationId="actionGetByData",
     summary="Find tariffs",
     @SWG\Parameter(
         name="type",
         in="query",
         type="string",
         required=true,
         description="Type of connect",
     ),
     @SWG\Parameter(
         name="find_data[0][service]",
         in="query",
         type="string",
         required=true,
         description="Client",
     ),
     @SWG\Parameter(
         name="find_data[0][tariff]",
         in="query",
         type="string",
         required=true,
         description="Tariff",
     ),
     @SWG\Parameter(
         name="find_data[0][connection]",
         in="query",
         type="string",
         required=true,
         description="Connection",
     ),
     @SWG\Response(
         response = 200,
         description = "Success",
         @SWG\Schema(
            @SWG\Property(property="id", type="integer", description="Id tariff")
         )
     )
)

but in swagger it doesn't look very nice, especially when trying to query in ui.

Also I tried make like here. I changed in="body" on in="query", but it gave out an error Failed to load API definition. Fetch errorInternal Server Error /api/docs/json-schema

  • 1
    OpenAPI Specification [does not support](https://stackoverflow.com/q/52892768/113116) arrays of objects in the query string. – Helen Apr 12 '23 at 16:32
  • I voted up for @Helen answer. You need to use OpenApi 3 instead of 2. – SiZE Apr 14 '23 at 08:16

0 Answers0