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

Possible to override Parameter Schema? #1583

Open
akshare opened this issue Apr 30, 2024 · 3 comments
Open

Possible to override Parameter Schema? #1583

akshare opened this issue Apr 30, 2024 · 3 comments

Comments

@akshare
Copy link

akshare commented Apr 30, 2024

Given this:

@OA\Parameter(
    parameter="sort_by",
    name="sort_by",
    in="query",
    description="Sort by field",
    required=false
),

Is it possible to add/override Schema in the referenced Parameter or some other way to handle this?

Basically, the parameter properties should remain the same (name, in, description, required) and should be reusable while Schema may be different for each implementation.

I understand the example below is incorrect, but it's just for context for what I'm trying to accomplish.


@OA\Get(
    path="/test/{id}",
    tags={"Test"},
    summary="Get specific tests by id",
    @OA\Parameter(
           ref="#/components/parameters/sort_by"
           @OA\Schema(
               type="string",
	       enum={"name","id"},
	       default="name"
           )
    )
),
@DerManoMann
Copy link
Collaborator

I think the first step would be to try to figure out if this is possible to express in OpenApi yaml/json itself. If so, we can start thinking about how to build it from existing annotations.

@akshare
Copy link
Author

akshare commented Apr 30, 2024

@DerManoMann your suggestion helped to refine my search.

I think this might work for me, and will update here if I get it to work.

https://stackoverflow.com/questions/27005105/swagger-openapi-use-ref-to-pass-a-reusable-defined-parameter

@akshare
Copy link
Author

akshare commented Apr 30, 2024

It doesn't seem possible yet.

OAI/OpenAPI-Specification#2029

OAI/OpenAPI-Specification#2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants