Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref in @OA\Header #570

Closed
jwadhams opened this issue Aug 15, 2018 · 3 comments
Closed

Ref in @OA\Header #570

jwadhams opened this issue Aug 15, 2018 · 3 comments

Comments

@jwadhams
Copy link

It looks like it should be possible, inside a Response, to have a Header that's just a reference to a definition in the Components. Here's an example in the generated yaml: OAI/OpenAPI-Specification#1445 (comment)

I would have expected something like this to work:

 * @OA\Header(
 *     header="X-RateLimit-Remaining",
 *     description="The number of remaining requests in the period",
 *     @OA\Schema( type="integer" )
 * ),
 *
 * @OA\Response(
 *     response="Standard400BadRequestResponse",
 *     description="Bad request, validation error",
 *     @OA\Schema(ref="#/components/schemas/Error"),
 *     @OA\Header(ref="#/components/headers/X-RateLimit-Limit"),
 * ),

but I get the errors Unexpected field "ref" and @OA\Header() is missing key-field: "header"

@bfanger
Copy link
Collaborator

bfanger commented Aug 16, 2018

Fixed, Thanks for reporting the issue.

Ps:
For now, you still need to specify the header, so inside the @OA\Response you'd write:

 *    @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining")

@jpuck
Copy link
Contributor

jpuck commented Jan 25, 2019

@bfanger we're running 3.0.2, which contains the fix in 67f5173 but we still are getting the warning unless specifying the header="X-RateLimit-Remaining" as in your proposed workaround above. thanks!

@bfanger
Copy link
Collaborator

bfanger commented Feb 4, 2019

@jpuck that is by design, this way you the propertyname in the components.headers object doesn't have to match the propertyname in the response
.headers object.

Doqnach pushed a commit to Doqnach/swagger-php that referenced this issue Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants