alt3 / cakephp-swagger Goto Github PK
View Code? Open in Web Editor NEWSwagger plugin for documenting your CakePHP APIs
License: MIT License
Swagger plugin for documenting your CakePHP APIs
License: MIT License
2019-01-03 19:22:12 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Alt3 could not be found.
Request URL: /alt3/swagger
i cannot figure out the problem, it runs fine on my local system but on our staging server there is this issue
Hi, I Need swagger ui for cakephp2.x kindly share your points
Hardcoded icon links found here should be generated using HtmlHelper.
<link rel="icon" type="image/png" href="http://api.local/images/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="http://api.local/images/favicon-16x16.png" sizes="16x16" />
Placeholder for https://github.com/swagger-api/swagger-ui/releases/tag/v3.0.0, needs investigating.
I have a parameter defined as
@swg\Parameter(
name="id",
description="contact primary id",
in="path",
required=false,
type="integer",
)
On the UI it shows correctly as
Description | Parameter Type | Data Type |
---|---|---|
contact primary id | path | integer |
When I click the try it now the try it now button the Value i entered doesnt get added to the path.
Any ideas?
Thanks
Automated deployments could do with Shell creating the cache files
I have the following annotation :
/** @SWG\Swagger( schemes={"http", "https"}, host="API_HOST", basePath="/api", @SWG\Info( version="1.0.0", title="...", ) ) */
But when i press "Try it out", the request url does not include the basePath.
I've seen the lib/SwaggerTools file containing line 50 :
// set object properties required by UI to generate the BASE URL $swagger->host = $host; $swagger->basePath = '/' . Configure::read('App.base');
Is there any way to use api_key
to represent 'Authorization: Bearer <token>'
in header.
I recently updated my project to CakePHP 4.3, and I get this message:
[Deprecated (16384)](javascript:void(0);): `Router::plugin()` is deprecated, use the non-static method `RouteBuilder::plugin()` instead.
/var/www/repo/public/vendor/alt3/cakephp-swagger/config/routes.php, line: 56
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `vendor/alt3/cakephp-swagger/config/routes.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only. [CORE/src/Core/functions.php, line 321]
I think the fix is quite easy (I've done it in my project already), Router::plugin()
just needs to be changed to $routes->plugin()
in config/routes.php
.
If needed, I can open a pull request for that.
Hey guys, thank you for a great plugin:)
I've been having some trouble working with the validator, I only get appropriate errors on the docs page, and the page has to be refreshed in order to check for errors which I find tiresome.
So to fix this I've created a small gulp script which watches for changes in my files. Upon a detected change, the script validates the swagger doc and generate a new doc that I save to another repository to which my clients are subscribed too.
I thought you might find it useful, so here it is:)
var gulp = require('gulp');
var swagger = require('gulp-swagger');
const shell = require('gulp-shell')
var api_path = './src/controller/api/**/*.php'
var definitions_path = './src/model/swagger/**/*.php';
var swagger_json_path = './tmp/cache/cakephp_swagger_api.json';
gulp.task('validate', function() {
gulp.src(swagger_json_path)
.pipe(swagger('athgene_internal_api.json'))
.pipe(gulp.dest('PATH_TO_REPO'));
});
gulp.task('compile_swagger', shell.task([
'./bin/cake swagger makedocs localhost:8765'
]));
gulp.task('default', ['validate']);
// Rerun the task when a file changes
gulp.task('watch', function () {
gulp.watch(api_path, ['compile_swagger']);
gulp.watch(definitions_path, ['compile_swagger']);
gulp.watch(swagger_json_path, ['validate']);
});
DocsController
should generate the three fields used by Swagger-UI to generate and show the Base Url:
basePath="/v0",
host="your.api.local",
schemes={"http", "https"},
NEVER specify these fields in the source code annotations as this will break deploying your app to environments using no/different basePath.
Update:
Only schemes
should be configurable, basePath
and host
can be fetched realtime.
More information:
In cakephp-swagger/src/Template/Ui/index.ctp
file, $userConfig
should be $uiConfig
. Currently the title field never gets reflected with what is being set in swagger.php
file because $userConfig
is not set from the controller, only $uiConfig
is set.
s it possible to use downgrade cakephp 2.x ?
Error: "Not found"
In localhost with Apache always works fine. Why I got 404 in Nginx server? I need configure the Nginx to find swagger?
Someone know something??
Browser complains about insecure media when connecting to UI using HTTPS..
Update:
The warning is a known issue, to be fixed by the swagger team, caused by the Ui-generated validator button so... no issues in our index.ctp
as explained by Chrome:
Mixed Content: The page at 'https://api.local/swagger' was loaded over HTTPS, but requested an insecure image 'http://online.swagger.io/validator/?url=https://api.local/swagger/docs/api'. This content should also be served over HTTPS.
See also:
Replace the current (flakey) caching mechanism used to store the generated documents by actual filesystem documents/files. This would:
Hello, I'm stuck with mixed content error.
I'm on cloud hosting running https, but swagger try to load assets in HTTP.
Here is my swagger configuration
`
use Cake\Core\Configure;
return [
'Swagger' => [
'ui' => [
'title' => 'PBE API Documentation',
'validator' => true,
'api_selector' => true,
'route' => 'api/swagger/',
'schemes' => ['https']
],
'docs' => [
'crawl' => Configure::read('debug'),
'route' => '/swagger/docs/',
'cors' => [
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET, POST',
'Access-Control-Allow-Headers' => 'X-Requested-With'
]
],
'library' => [
'api' => [
'include' => ROOT . DS . 'src' . DS . 'Controller' . DS . 'Api',
'exclude' => [
'/Editor/'
]
]
]
]
];
`
Locally it works but not in production.
I don't understand.
Thank you, for your time
Hey,
First of all, thanks for the plugin!
Having the API basePath derived from Configure::read('App.base') is good, but if you have an application where your API endpoints are prefixed (e.g. /api) and this app also serves static content or crud as the webpages this might be an issue.
So, having an option to define API basePath via annotations might help. Basically, if basePath is defined via annotations we use it or App.base otherwise.
The fix is quite trivial but I can create a PR if needed.
Thanks!
Codecov.io currently not generating coverage reports even though the last PR hit a 100%
Im my localhost swagger works well, but when I upload to a web service with server Nginx I am got this error: Can't read swagger JSON from https://servername/swagger/docs/api
someone know why??
As far as I understand, cakephp-swagger uses php-swagger in version 2 which did not support OpenApi 3. Is it possible to use cakephp-swagger with php-swagger version 3? Composer doesn't allow me to install php-swagger version 3 due to the requirements of cakephp-swagger.
Can we have a new major release compatible with CakePHP 3.6. I am up for the migration, are you accepting MRs?
Looks like it's quite easy to turn on/off the validation button which is a good thing since not all APIs will be publicly accessible.
Instead of throwing an exception on the index action requiring an argument we could show a json list of (config-enabled?) documents.
Add this plugin to the list at http://swagger.io/open-source-integrations/
Travis HHVM chokes on phpunit with:
Fatal error: Stack overflow
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.