For OpenAPI (swagger-php), how do I auto generate query parameters?How can I prevent SQL injection in PHP?How do I get PHP errors to display?How do you parse and process HTML/XML in PHP?How does PHP 'foreach' actually work?File upload on Swagger Editor OpenAPI 3 not showing the file browser when trying it outDisplay json object properties in parameters list in Swagger UIGenerate swagger-ui page from schema yaml file using swagger-codegen-maven-pluginHow to define a reusable body parameter that is a primitive data type in OpenAPI 3.0?How to specify the schema of a reusable request body parameter in OpenAPI 3.0How to generate SpringBoot models from Swagger yaml with Openapi Generator

In Dutch history two people are referred to as "William III"; are there any more cases where this happens?

Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?

Why does string strummed with finger sound different from the one strummed with pick?

Windows reverting changes made by Linux to FAT32 partion

Why is so much ransomware breakable?

Combining two Lorentz boosts

Is it a good idea to teach algorithm courses using pseudocode?

Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario

Bookshelves: the intruder

French equivalent of the German expression "flöten gehen"

Was Tyrion always a poor strategist?

Pedaling at different gear ratios on flat terrain: what's the point?

When did Britain learn about the American Declaration of Independence?

Save my secrets!

How many Dothraki are left as of Game of Thrones S8E5?

Should I twist DC power and ground wires from a power supply?

What's is the easiest way to purchase a stock and hold it

Parse a C++14 integer literal

Alternative classical explanation of the Stern-Gerlach Experiment?

Why aren't satellites disintegrated even though they orbit earth within earth's Roche Limits?

Driving a school bus in the USA

Working hours and productivity expectations for game artists and programmers

on the truth quest vs in the quest for truth

Why is Drogon so much better in battle than Rhaegal and Viserion?



For OpenAPI (swagger-php), how do I auto generate query parameters?


How can I prevent SQL injection in PHP?How do I get PHP errors to display?How do you parse and process HTML/XML in PHP?How does PHP 'foreach' actually work?File upload on Swagger Editor OpenAPI 3 not showing the file browser when trying it outDisplay json object properties in parameters list in Swagger UIGenerate swagger-ui page from schema yaml file using swagger-codegen-maven-pluginHow to define a reusable body parameter that is a primitive data type in OpenAPI 3.0?How to specify the schema of a reusable request body parameter in OpenAPI 3.0How to generate SpringBoot models from Swagger yaml with Openapi Generator






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am writing an OpenAPI spec and trying to generate my possible query parameters automatically (using swagger-php) from the annotations for a request route/path. I know that I can just type out all possible parameter options for each route, but I really need to be able to generate the possible parameters from the properties of a class automatically using annotations like I can do for the request body. (We will have tons of classes/paths and keeping it up to date most likely won't happen unless they are generated like the request body/JsonContent can be. Is this possible with swagger-php or even OpenAPI in general?



I got this to work with the put and the request body, but how do I do it for a get request that still uses the properties of the class?



I can do this for the request body:



 /**
* @return Response
*
* * @OAPut(
* path="/persons",
* tags="Person",
* @OARequestBody(
* request="person",
* required=false,
* description="Optional Request Parameters for Querying",
* @OAJsonContent(ref="#/components/schemas/Person")
* ),
* @OAResponse(
* response="200",
* description="Returns matching Person Object",
* @OAJsonContent(
* type="array",
* @OAItems(ref="#/components/schemas/Person")
* )
* )
* )
*/


Writing out each parameter for 30+ classes will not be maintainable:



 /** @OAGet(
* path="/events",
* tags="Events",
* @OAParameter(
* name="eventID",
* in="query",
* required=false,
* description="The event ID specific to this event",
* @OASchema(
* type="string"
* ),
* ),
*
* ....etc









share|improve this question
























  • Don't take that path. The annotation lines tend to overcome the size of the method they describe, and the language is not the most expressive. The developers tend to hate that code as is not readable.

    – Alex
    Mar 24 at 0:21






  • 1





    I'm actually the main developer (for now) and feel like having it in the comments means it may actually stay up to date. That's why I'm trying to pull the query params automatically from the properties like I can with the request body. That should at least guarantee that part status up to date with minimal effort, right? Are you saying that it can't be done automatically though? Or just that you wouldn't recommend it? Regardless, what would you recommended then?

    – Joey Overby
    Mar 25 at 3:15











  • Have a look here medium.com/@giuvara.alex/…, it describes the pains of another PHP developer trying to automate the documentation process. In short, is better to create the OAS file by hand and update it before you implement the functionality (Documentation Driven Development)

    – Alex
    Mar 25 at 10:39

















0















I am writing an OpenAPI spec and trying to generate my possible query parameters automatically (using swagger-php) from the annotations for a request route/path. I know that I can just type out all possible parameter options for each route, but I really need to be able to generate the possible parameters from the properties of a class automatically using annotations like I can do for the request body. (We will have tons of classes/paths and keeping it up to date most likely won't happen unless they are generated like the request body/JsonContent can be. Is this possible with swagger-php or even OpenAPI in general?



I got this to work with the put and the request body, but how do I do it for a get request that still uses the properties of the class?



I can do this for the request body:



 /**
* @return Response
*
* * @OAPut(
* path="/persons",
* tags="Person",
* @OARequestBody(
* request="person",
* required=false,
* description="Optional Request Parameters for Querying",
* @OAJsonContent(ref="#/components/schemas/Person")
* ),
* @OAResponse(
* response="200",
* description="Returns matching Person Object",
* @OAJsonContent(
* type="array",
* @OAItems(ref="#/components/schemas/Person")
* )
* )
* )
*/


Writing out each parameter for 30+ classes will not be maintainable:



 /** @OAGet(
* path="/events",
* tags="Events",
* @OAParameter(
* name="eventID",
* in="query",
* required=false,
* description="The event ID specific to this event",
* @OASchema(
* type="string"
* ),
* ),
*
* ....etc









share|improve this question
























  • Don't take that path. The annotation lines tend to overcome the size of the method they describe, and the language is not the most expressive. The developers tend to hate that code as is not readable.

    – Alex
    Mar 24 at 0:21






  • 1





    I'm actually the main developer (for now) and feel like having it in the comments means it may actually stay up to date. That's why I'm trying to pull the query params automatically from the properties like I can with the request body. That should at least guarantee that part status up to date with minimal effort, right? Are you saying that it can't be done automatically though? Or just that you wouldn't recommend it? Regardless, what would you recommended then?

    – Joey Overby
    Mar 25 at 3:15











  • Have a look here medium.com/@giuvara.alex/…, it describes the pains of another PHP developer trying to automate the documentation process. In short, is better to create the OAS file by hand and update it before you implement the functionality (Documentation Driven Development)

    – Alex
    Mar 25 at 10:39













0












0








0








I am writing an OpenAPI spec and trying to generate my possible query parameters automatically (using swagger-php) from the annotations for a request route/path. I know that I can just type out all possible parameter options for each route, but I really need to be able to generate the possible parameters from the properties of a class automatically using annotations like I can do for the request body. (We will have tons of classes/paths and keeping it up to date most likely won't happen unless they are generated like the request body/JsonContent can be. Is this possible with swagger-php or even OpenAPI in general?



I got this to work with the put and the request body, but how do I do it for a get request that still uses the properties of the class?



I can do this for the request body:



 /**
* @return Response
*
* * @OAPut(
* path="/persons",
* tags="Person",
* @OARequestBody(
* request="person",
* required=false,
* description="Optional Request Parameters for Querying",
* @OAJsonContent(ref="#/components/schemas/Person")
* ),
* @OAResponse(
* response="200",
* description="Returns matching Person Object",
* @OAJsonContent(
* type="array",
* @OAItems(ref="#/components/schemas/Person")
* )
* )
* )
*/


Writing out each parameter for 30+ classes will not be maintainable:



 /** @OAGet(
* path="/events",
* tags="Events",
* @OAParameter(
* name="eventID",
* in="query",
* required=false,
* description="The event ID specific to this event",
* @OASchema(
* type="string"
* ),
* ),
*
* ....etc









share|improve this question
















I am writing an OpenAPI spec and trying to generate my possible query parameters automatically (using swagger-php) from the annotations for a request route/path. I know that I can just type out all possible parameter options for each route, but I really need to be able to generate the possible parameters from the properties of a class automatically using annotations like I can do for the request body. (We will have tons of classes/paths and keeping it up to date most likely won't happen unless they are generated like the request body/JsonContent can be. Is this possible with swagger-php or even OpenAPI in general?



I got this to work with the put and the request body, but how do I do it for a get request that still uses the properties of the class?



I can do this for the request body:



 /**
* @return Response
*
* * @OAPut(
* path="/persons",
* tags="Person",
* @OARequestBody(
* request="person",
* required=false,
* description="Optional Request Parameters for Querying",
* @OAJsonContent(ref="#/components/schemas/Person")
* ),
* @OAResponse(
* response="200",
* description="Returns matching Person Object",
* @OAJsonContent(
* type="array",
* @OAItems(ref="#/components/schemas/Person")
* )
* )
* )
*/


Writing out each parameter for 30+ classes will not be maintainable:



 /** @OAGet(
* path="/events",
* tags="Events",
* @OAParameter(
* name="eventID",
* in="query",
* required=false,
* description="The event ID specific to this event",
* @OASchema(
* type="string"
* ),
* ),
*
* ....etc






php swagger openapi swagger-php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 17:34







Joey Overby

















asked Mar 23 at 17:29









Joey OverbyJoey Overby

164




164












  • Don't take that path. The annotation lines tend to overcome the size of the method they describe, and the language is not the most expressive. The developers tend to hate that code as is not readable.

    – Alex
    Mar 24 at 0:21






  • 1





    I'm actually the main developer (for now) and feel like having it in the comments means it may actually stay up to date. That's why I'm trying to pull the query params automatically from the properties like I can with the request body. That should at least guarantee that part status up to date with minimal effort, right? Are you saying that it can't be done automatically though? Or just that you wouldn't recommend it? Regardless, what would you recommended then?

    – Joey Overby
    Mar 25 at 3:15











  • Have a look here medium.com/@giuvara.alex/…, it describes the pains of another PHP developer trying to automate the documentation process. In short, is better to create the OAS file by hand and update it before you implement the functionality (Documentation Driven Development)

    – Alex
    Mar 25 at 10:39

















  • Don't take that path. The annotation lines tend to overcome the size of the method they describe, and the language is not the most expressive. The developers tend to hate that code as is not readable.

    – Alex
    Mar 24 at 0:21






  • 1





    I'm actually the main developer (for now) and feel like having it in the comments means it may actually stay up to date. That's why I'm trying to pull the query params automatically from the properties like I can with the request body. That should at least guarantee that part status up to date with minimal effort, right? Are you saying that it can't be done automatically though? Or just that you wouldn't recommend it? Regardless, what would you recommended then?

    – Joey Overby
    Mar 25 at 3:15











  • Have a look here medium.com/@giuvara.alex/…, it describes the pains of another PHP developer trying to automate the documentation process. In short, is better to create the OAS file by hand and update it before you implement the functionality (Documentation Driven Development)

    – Alex
    Mar 25 at 10:39
















Don't take that path. The annotation lines tend to overcome the size of the method they describe, and the language is not the most expressive. The developers tend to hate that code as is not readable.

– Alex
Mar 24 at 0:21





Don't take that path. The annotation lines tend to overcome the size of the method they describe, and the language is not the most expressive. The developers tend to hate that code as is not readable.

– Alex
Mar 24 at 0:21




1




1





I'm actually the main developer (for now) and feel like having it in the comments means it may actually stay up to date. That's why I'm trying to pull the query params automatically from the properties like I can with the request body. That should at least guarantee that part status up to date with minimal effort, right? Are you saying that it can't be done automatically though? Or just that you wouldn't recommend it? Regardless, what would you recommended then?

– Joey Overby
Mar 25 at 3:15





I'm actually the main developer (for now) and feel like having it in the comments means it may actually stay up to date. That's why I'm trying to pull the query params automatically from the properties like I can with the request body. That should at least guarantee that part status up to date with minimal effort, right? Are you saying that it can't be done automatically though? Or just that you wouldn't recommend it? Regardless, what would you recommended then?

– Joey Overby
Mar 25 at 3:15













Have a look here medium.com/@giuvara.alex/…, it describes the pains of another PHP developer trying to automate the documentation process. In short, is better to create the OAS file by hand and update it before you implement the functionality (Documentation Driven Development)

– Alex
Mar 25 at 10:39





Have a look here medium.com/@giuvara.alex/…, it describes the pains of another PHP developer trying to automate the documentation process. In short, is better to create the OAS file by hand and update it before you implement the functionality (Documentation Driven Development)

– Alex
Mar 25 at 10:39












1 Answer
1






active

oldest

votes


















0














Swagger-PHP requires annotations to document the query parameters. You can reduce code duplication somewhat by adding top-level @OAParameter annotations that can be referenced using $ref="#/components/parameters/PARAM_NAME", as shown here and here.



/**
* @OAParameter(
* parameter="eventID_in_query",
* name="eventID",
* description="The event ID specific to this event",
* @OASchema(
* type="string"
* ),
* in="query",
* required=false
* )
*/

...

/** @OAGet(
* path="/events",
* tags="Events",
* @OAParameter(ref="#/components/parameters/eventID_in_query"),





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316486%2ffor-openapi-swagger-php-how-do-i-auto-generate-query-parameters%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Swagger-PHP requires annotations to document the query parameters. You can reduce code duplication somewhat by adding top-level @OAParameter annotations that can be referenced using $ref="#/components/parameters/PARAM_NAME", as shown here and here.



    /**
    * @OAParameter(
    * parameter="eventID_in_query",
    * name="eventID",
    * description="The event ID specific to this event",
    * @OASchema(
    * type="string"
    * ),
    * in="query",
    * required=false
    * )
    */

    ...

    /** @OAGet(
    * path="/events",
    * tags="Events",
    * @OAParameter(ref="#/components/parameters/eventID_in_query"),





    share|improve this answer



























      0














      Swagger-PHP requires annotations to document the query parameters. You can reduce code duplication somewhat by adding top-level @OAParameter annotations that can be referenced using $ref="#/components/parameters/PARAM_NAME", as shown here and here.



      /**
      * @OAParameter(
      * parameter="eventID_in_query",
      * name="eventID",
      * description="The event ID specific to this event",
      * @OASchema(
      * type="string"
      * ),
      * in="query",
      * required=false
      * )
      */

      ...

      /** @OAGet(
      * path="/events",
      * tags="Events",
      * @OAParameter(ref="#/components/parameters/eventID_in_query"),





      share|improve this answer

























        0












        0








        0







        Swagger-PHP requires annotations to document the query parameters. You can reduce code duplication somewhat by adding top-level @OAParameter annotations that can be referenced using $ref="#/components/parameters/PARAM_NAME", as shown here and here.



        /**
        * @OAParameter(
        * parameter="eventID_in_query",
        * name="eventID",
        * description="The event ID specific to this event",
        * @OASchema(
        * type="string"
        * ),
        * in="query",
        * required=false
        * )
        */

        ...

        /** @OAGet(
        * path="/events",
        * tags="Events",
        * @OAParameter(ref="#/components/parameters/eventID_in_query"),





        share|improve this answer













        Swagger-PHP requires annotations to document the query parameters. You can reduce code duplication somewhat by adding top-level @OAParameter annotations that can be referenced using $ref="#/components/parameters/PARAM_NAME", as shown here and here.



        /**
        * @OAParameter(
        * parameter="eventID_in_query",
        * name="eventID",
        * description="The event ID specific to this event",
        * @OASchema(
        * type="string"
        * ),
        * in="query",
        * required=false
        * )
        */

        ...

        /** @OAGet(
        * path="/events",
        * tags="Events",
        * @OAParameter(ref="#/components/parameters/eventID_in_query"),






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 16:47









        HelenHelen

        35.9k585136




        35.9k585136





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316486%2ffor-openapi-swagger-php-how-do-i-auto-generate-query-parameters%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현