Replies: 2 comments
-
Hi! I haven't done the setup myself, but I worked with a craft project where https://github.com/zircote/swagger-php and https://github.com/swagger-api/swagger-ui was used to generate swagger docs for a module and the controller actions in it. Would be cool to have a tutorial for setting that up, weird that there is none yet online (or I missed it). Much success! |
Beta Was this translation helpful? Give feedback.
-
yii-swagger appears to be a Yii3 extension. (Not clearly stated, but the routing example is very Yii3.) I haven’t tried it, but take a look at ignatenkovnikita/yii2-swagger, which was written for Yii2 (which Craft currently uses). |
Beta Was this translation helpful? Give feedback.
-
This is my first CraftCMS project and I might be missing obvious knowledge. I am trying to implement Swagger on a module with a REST API with yii-swagger. yii-swagger requires yii-router, which appears to me to be incompatible with CraftCMS. Or is it possible to make it work together with the default craft routing?
Then I tried to call the SwaggerUI action class of yii-swagger in a Craft controller. This is not possible via dependency injection. I assume it is related to the Yii2 ViewRenderer class that is used in the SwaggerUI action.
Is it possible to use yii-swagger? Or is there another recommended way to support Swagger in Craft?
Would it be best to implement it from scratch with https://github.com/zircote/swagger-php and https://github.com/swagger-api/swagger-ui?
I am also wondering why the dependency injection does not work in action functions in Craft. This example should work in yii:
Is it only possible to inject dependencies via the constructor in Craft?
Beta Was this translation helpful? Give feedback.
All reactions