I am trying to define the request body as a simple array of strings like this:
@SWG\Parameter(
* in="body",
* description="List of ids",
* required=true,
* type="array",
* @SWG\Items(type="string")
* ),
The resulting data type/model is just
Array[string]
Can this be any better?
At the same time the response should be a single array of strings which also seems to be an issue as no matter what I've tried so far it mostly looks like this:
{
"ids": []
}
Is there perhaps a list of simple examples on how to create some of these basic structures?
No list that I know of, let me know if you find one, so i can link it in the docs.
The json-schema.org has some examples to get a feel for defining the data-structures.
* @SWG\Response(
* response=200,
* description="List of ids",
* @SWG\Schema(
* type="array",
* @SWG\Items(type="string")
* )
* )
Thinking too complicated !
Thanks.
/**
* @OA\Schema(
* schema="PostRequest",
* type="object",
* @OA\Property(
* property="images",
* description="The images URL",
* type="array",
* @OA\Items(type="string")
* )
* )
*/
Now you can use the Schema in the service's description:
/**
* @OA\Post(
* path="/posts",
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/PostRequest")
* )
* ),
* )
*/
Most helpful comment
No list that I know of, let me know if you find one, so i can link it in the docs.
The json-schema.org has some examples to get a feel for defining the data-structures.