fgsl / swagger-docs
Swagger Documentation Generator
Installs: 132
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:component
Requires
- php: >=7.2
- zircote/swagger-php: ^3.0
Requires (Dev)
- phing/phing: ^2.16
This package is auto-updated.
Last update: 2024-10-26 22:40:51 UTC
README
Run command:
composer require fgsl/swagger-docs
For getting Composer: https://getcomposer.org/download/
How to use
See sample below:
vendor/bin/fsd
Defaults: source directory: src/ target directory: public/.
For an alternative source directory, pass the directory name as first argument.
For an alternative target directory, pass the directory name as second argument.
So:
vendor/bin/fsd [sourceDirectory] [targetDirectory]
[sourceDirectory] and [targetDirectory] are relative to root directory of application.
Build
vendor/bin/phing
Dependency
This project depends on swagger-php.
Annotations
Read about annotations in swagger-php annotations.
But maybe you can learn better by examples.
Model for API page
The following page shows the documentation generated by this component. You only need to replace [WEB ROOT ROUTE] bu the root URL of your application.
For example, for a Laminas PHP application, [WEB ROOT ROUTE] is <?=$this->url('home')?>
.
<!-- HTML for static distribution bundle build --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Swagger UI</title> <link rel="stylesheet" type="text/css" href="[WEB ROOT ROUTE]swagger-ui.css" > <link rel="icon" type="image/png" href="[WEB ROOT ROUTE]>favicon-32x32.png" sizes="32x32" /> <link rel="icon" type="image/png" href="[WEB ROOT ROUTE]>favicon-16x16.png" sizes="16x16" /> <style> html { box-sizing: border-box; overflow: -moz-scrollbars-vertical; overflow-y: scroll; } *, *:before, *:after { box-sizing: inherit; } body { margin:0; background: #fafafa; } </style> </head> <body> <div id="swagger-ui"></div> <script src="[WEB ROOT ROUTE]swagger-ui-bundle.js"> </script> <script src="[WEB ROOT ROUTE]swagger-ui-standalone-preset.js"> </script> <script src="[WEB ROOT ROUTE]spec.js"> </script> <script> window.onload = function() { // Begin Swagger UI call region const ui = SwaggerUIBundle({ //url: "https://petstore.swagger.io/v2/swagger.json", spec : spec, dom_id: '#swagger-ui', deepLinking: true, presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], plugins: [ SwaggerUIBundle.plugins.DownloadUrl ], layout: "StandaloneLayout" }) // End Swagger UI call region window.ui = ui } </script> </body> </html>