jdesrosiers / silex-swagger-provider

A silex service provider that integrates swagger-php into silex
MIT License
21 stars 10 forks source link

Please provide an example of using silex with php-swagger. #3

Closed diaspar closed 11 years ago

diaspar commented 11 years ago

As far as I understand, doctrine annotations needs a Class/Method structure to discover the annotations:

https://github.com/zircote/swagger-php/issues/9

I have this structure on my silex app

vendor web/index.php

Inside index.php I have

$app->register(new JDesrosiers\Silex\Provider\SwaggerServiceProvider(), array(
    "swagger.srcDir" => __DIR__ . "/../vendor/zircote/swagger-php/library",
    "swagger.servicePath" => __DIR__ . "/",
));

/**
 *
 * @SWG\Api(
 *   path="/pet.{format}/{petId}",
 *   description="Operations about pets"
 * )
 */

$app->get('/hello/{name}', function ($name) use ($app) {
    return 'Hello '.$app->escape($name);
});

But everytime I go to: web/index.php/api-docs.json

I only see this : [ ]

This produces an error:

web/index.php/resources/pet.json

I suppose doctrine is not reaching the annotations.

Am I missing something?

jdesrosiers commented 11 years ago

Looks like you figured it out, but I will add a more detailed usage example to the README.

diaspar commented 11 years ago

Yea, the referenced ticket on php-swagger gave me a clue about what I did wrong.

I checked, your code, great provider, really easy to integrate with silex after you figure it out how to write a proper annotation.

thanks for adding more instructions to the README