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

Provide support for non-oop annotated development to be parsed. #9

Closed
zircote opened this issue Jul 9, 2012 · 7 comments
Closed

Provide support for non-oop annotated development to be parsed. #9

zircote opened this issue Jul 9, 2012 · 7 comments
Assignees
Labels

Comments

@zircote
Copy link
Owner

zircote commented Jul 9, 2012

Expand annotation awareness to not be method specific but also closures and no class structure implementations similar to

  • Silex
  • Kohana

Example:

<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
/**
 * @SwaggerResource(
 *     basePath="http://silex.local/api",
 *     swaggerVersion="1.0",
 *     apiVersion="1"
 * )
 * @Swagger (
 *     path="/pets",
 *     value="Gets collection of pets",
 *     description="This is a long description of what it does"
 *     )
 * @SwaggerProduces (
 *     'application/json',
 *     'application/json-p',
 *     'application/xml',
 *     )
 *
 */
$app = new Silex\Application();

/**
 *
 * @PUT
 * @SwaggerPath /{petId}
 * @SwaggerOperation(
 *     value="Updates the existing pet designated by the {petId}",
 *     responseClass="pet",
 *     multiValueResponse=false,
 *     tags="Pet"
 * )
 * @SwaggerError(code=400,reason="Invalid ID Provided")
 * @SwaggerError(code=403,reason="User Not Authorized")
 * @SwaggerError(code=404,reason="Lead Responder Not Found")
 * @SwaggerParam(
 *     description="ID of the route being requested",
 *     required=true,
 *     allowMultiple=false,
 *     dataType="integer",
 *     name="petId",
 *     paramType="path"
 * ) 
 * @SwaggerParam(
 *     description="pet being updated",
 *     required=true,
 *     allowMultiple=false,
 *     dataType="pet",
 *     name="pet",
 *     paramType="body"
 * )
 *
 * @ResponseTypeInternal Model_Pet
 *
 */
$app->match('/pets/{petId}', function () {
    /*
     * Edit a pet
     */
})->method('PUT');

$app->run();
@ghost ghost assigned zircote Jul 9, 2012
@tonivdv
Copy link

tonivdv commented Aug 22, 2012

Hello Zircota,

Any idea when that would be implemented? Or any technical insights so I could help with that? I'm currently writing an API in Silex, and I'm really missing the "auto-documentation" of that API.

@zircote
Copy link
Owner Author

zircote commented Aug 22, 2012

I have not put any thought into this in the last few weeks as I have been distracted with a few hundred other things at work. However I will put some thought into it this week and devise a plan for this and get back to you when I have a more concise idea.

@zircote
Copy link
Owner Author

zircote commented Nov 26, 2012

I need to test this, however I am not certain what support Doctrine will give for non-oo code bases at this time but I fear it may not be much help. That said I have spent no time at all looking into it as of yet but will in the next week or so.

@zircote
Copy link
Owner Author

zircote commented Dec 16, 2012

As a note this has been on my mind for a while. At this time; however the Doctrine annotations do not support file and function level annotations discovery. I am looking into ways to extend it to support this or another route to achieve this goal.

@zircote zircote closed this as completed Mar 25, 2013
@diaspar
Copy link

diaspar commented Aug 25, 2013

is there a workaround for this using silex?

@bfanger
Copy link
Collaborator

bfanger commented Aug 25, 2013

Since 0.6 you don't need classes anymore, as long as it's a *.php file and the annotations are in a doc-comment, you're good to go!

See https://github.com/zircote/swagger-php/blob/master/tests/SwaggerTests/Fixtures3/routes.php for an example.

PS.
I see you don't have a @swg\Resource around the @swg\Api in your example.

@diaspar
Copy link

diaspar commented Aug 25, 2013

Thanks a lot, you are right, it was a problem in the annotation.

I did a test with silex and worked great!!

Thanks again

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

No branches or pull requests

4 participants