Skip to content

Unable to set examples for response #17

@myshalov-taptima

Description

@myshalov-taptima

Hello, I'm facing kinda strange problem with response examples.

     *     @SWG\Response(
     *         response=500,
     *         description="Error response",
     *         examples={
     *         @SWG\Schema(
     *             @SWG\Property(property="data", type="object", description="Response payload", @SWG\Schema()),
     *             @SWG\Property(property="status", type="string", example=Message::CUSTOMER_IS_BLOCKED_MESSAGE, description="Status of request"),
     *             @SWG\Property(property="errors", type="array", description="Errors descriptions. Should be empty on success", example={},
     *                 @SWG\Items(default="[]")
     *             )
     *         )}
     *     )

It does not seem to work properly. I got empty 500 response (just an 500 code and description). After debugging for a while, I made a conclusion, that this vendor code just skips examples regardless of value I'm passing.

    protected function doMerge($data, $overwrite = false)
    {
        foreach ($data['examples'] ?? [] as $mimeType => $example) {
            $this->examples[$mimeType] = $this->examples[$mimeType] ?? null;
            MergeHelper::mergeFields($this->examples[$mimeType], $example, $overwrite);
        }

        $this->headers->merge($data['headers'] ?? [], $overwrite);

        $this->mergeDescription($data, $overwrite);
        $this->mergeExtensions($data, $overwrite);
        $this->mergeRef($data, $overwrite);
        $this->mergeSchema($data, $overwrite);
    }

What am i missing?

By the way, I have an additional question. My responses differ only on status property. I'd like to add an example just for this property. Is there a way for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions