darkaonline / swaggerlume Goto Github PK
View Code? Open in Web Editor NEWLumen swagger
License: MIT License
Lumen swagger
License: MIT License
Fetch errorFailed to fetch https://DOMAIN/docs
Fetch errorPossible cross-origin (CORS) issue? The URL origin (https://DOMAIN) does not match the page (http://DOMAIN). Check the server returns the correct 'Access-Control-Allow-*' headers.
I already added schemes={"http"},
, but it still opens as https as default. What can I do? I have lumen 5.6.
I installed by command: composer require "darkaonline / swagger-lume: 5.7. *"
but it does not seem to support lumen version 5.7
Please guide me how to install Swagger for Lumen 5.7
$this->app->group
can no longer be used, use app->route->..
instead
php artisan swagger-lume:generate
command gives error when upgraded to 5.6
Regenerating docs
In Logger.php line 38:
Required @OAS\Info() not found
I have an error while installing SwaggerLume to Limen 5.7
bootstrap/app.php:
$app->configure('swagger-lume');
$app->register(\SwaggerLume\ServiceProvider::class);
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi, i am trying to use SwaggerLume and i got this message after I run this command
swagger-lume:publish
I didn't config anything , everything is default.
I assume the config path is not correct, but I don't know how to fix it. Please help me thank you
I've just upgraded to 1.0.1 and the config setting
'key_var' => env('API_KEY_VAR', 'token'),
is no longer being used.
I found this commit that removed the references to apiKeyVar
from index.blade.php
.
Is there any other way to set a custom api_key
var?
HI,bro, I use lumen5.5 , this is my code:
/**
schemes={"http","https"},
host="api.host.com",
basePath="/",
@SWG\Info(
version="1.0.0",
title="This is my website cool API",
description="Api description...",
termsOfService="",
@SWG\Contact(
email="[email protected]"
),
@SWG\License(
name="Private License",
url="URL to the license"
)
),
@SWG\ExternalDocumentation(
description="Find out more about my website",
url="http..."
)
class LessionController extends Controller
{
/**
* @swg\Get(
* path="/Controller/LessionController/{customerId}/rate",
* summary="List customer rates",
* operationId="getCustomerRates",
* @swg\Parameter(
* name="customerId",
* in="path",
* description="Target customer.",
* required=true,
* type="integer"
* ),
* @swg\Parameter(
* name="filter",
* in="query",
* description="Filter results based on query string value.",
* required=false,
* enum={"active", "expired", "scheduled"},
* type="string"
* ),
* @swg\Response(response=200, description="successful operation"),
* @swg\Response(response=406, description="not acceptable"),
* @swg\Response(response=500, description="internal server error")
* )
*
*/
public function index() {
return [
'apple',
'orgran',
'banana',
];
}
}
I haved run command "php artisan swagger-lume:generate” it no error output
but http://xxxx/api/documentation show nothing
When following the installation at a certain point the following is said - added numbers for easier reference:
- (1) Run `php artisan swagger-lume:publish-config` to publish configs (`config/swagger-lume.php`)
- (2) Make configuration changes if needed
- (3) Run `php artisan swagger-lume:publish` to publish everything
But when you do exactly as said, after step 3 - all your configuration changes made in step 2 are reset.
Is this intended to happen or aren't these actual steps?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
visit xxx/api/documentation get Target [Illuminate\Contracts\Routing\UrlGenerator] is not instantiable. error
after laravel Upgrade 5.3 to 5.4
"php": ">=5.6.4",
"laravel/lumen-framework": "5.4.*",
"darkaonline/swagger-lume": "~2",
Currently I am copy pasting the json to swagger editor to display it.
I am expecting something like php artisan swagger-lume:view
to view the swagger doc.
Is this function available? or i just miss it cause i don't see any in documentation.
I'm on AWS Elastic BeanStalk with servers behind a load balancer. On lumen I have set it so that all http traffic is forwarded to https traffic.
However when I try to access /api/documentation via HTTPS swagger tried to pull the doc data from HTTP and I get the following error:
Can't read from server. It may not have the appropriate access-control-origin settings.
It's a minor issue since I have just manually fix http to https in the input field but a little annoying nonetheless.
I've tried adding
"view" => [
'Access-Control-Allow-Origin' => env('APP_URL')
]
but no effect.
Is there a workaround for this?
Hey, thanks a lot for your package, I'm using it to document my API written in Lumen (doh!).
I was wondering if it makes a big issue to update SwaggerUI to latest version? The current UI used in the package is almost a year old.
Because I need basic auth functionality I actually stopped using built-in UI and only using the package to generate the schema to be inserted in latest UI available on petstore... domain. That's quite sad as I need to instruct all api consumers here on how to actually load the api so they can test endpoints against specific authenticated user. And I want them to be just using swagger ui on our own domain with our schema loaded automatically.
It's not just that, current UI used also contains a lot of other bugs. For example, tooltips on models are broken which makes it very difficult to read tooltips.
Let me know if you have any plans to update the UI.
Thanks!
Are there any plans to support v3 of the OpenAPI Spec?
I might be missing appropriate configuration but I was trying to experiment this project by following the readme. I was able to publish the config but when I try to publish all or publish views from the console I get
[ErrorException]
mkdir(): Invalid path
debugging I got to this call sending NULL destinationPath
https://github.com/DarkaOnLine/SwaggerLume/blob/master/src/Console/PublishViewsCommand.php#L35
this config('swagger-lume.paths.views')
returns NULL
Can you point me to anything wrong that I'm doing or is this just a bug ?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hello,
I want to use another db instance for swagger documentation because if we use same db instance on production. there is fear of changes which can be made anyone who is using documentation. So different db for application and another one for documentation. How it can be done using swagger-lume???
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hello Dear,
Zircote package has been updated for open api annotations. Please update swagger lume as well. I am getting error that swagger/scan function does not exit.
Thanks
We have successfully integrated package (composer require "darkaonline/swagger-lume:5.5.*" ) with lumen 5.5 and swagger document generated successfully..
Now I want to integrate Open API 3.. please provide detail step by step to do it...
debug output:
[cosnis@m ~/Workspace]$ php artisan swagger-lume:generate
Regenerating docs
Swagger\Analysis {#288
+annotations: SplObjectStorage {#289
storage: array:1 [
"00000000324d6201000000001c85c54c" => array:2 [
"object" => Swagger\Annotations\OpenApi {#316
+openapi: "3.0.0"
+info: null <--- always throw error with this
+servers: null
+paths: []
+components: null
+security: null
+tags: null
+externalDocs: null
+_analysis: Swagger\Analysis {#288}
+x: null
+_context: Swagger\Context {#344
+"-": ""
}
+_unmerged: []
}
"info" => Swagger\Context {#344}
]
]
}
===
real output:
[cosnis@m ~/Workspace/]$ php artisan swagger-lume:generate
Regenerating docs
In Logger.php line 38:
Required @oas\Info() not found
[cosnis@m ~/Workspace/]$
i search on google, but only show what about SWG\Info(), not OAS\Info ....
with Lumen 5.6, command php artisan swagger-lume:generate
produce following error
Regenerating docs
In Logger.php line 38:
Required @SWG\Info() not found
When I try to navigate to api/documentation response SwaggerUIBundle is not defined. In the code, SwaggerUIBundle make reference to swagger-ui/dist/swagger-ui-bundle.js, but I don't know why response SwaggerUIBundle is not defined.
When i run the following command
php artisan swagger-lume:generate
and i see "No operations defined in spec!" on http://localhost/api/v1/documentation
Here is my base controller
namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Http\Request;
class Controller extends BaseController
{}
/**
* @SWG\Swagger(
* basePath=L5_SWAGGER_CONST_BASE_PATH,
* schemes={"http", "https"},
* host=L5_SWAGGER_CONST_HOST,
* @SWG\Info(
* version="1.0.0",
* title="L5 Swagger API",
* @SWG\Contact(
* email="[email protected]"
* ),
* )
* )
*/
/**
* @SWG\Tag(
* name="users",
* description="Operations about user",
* @SWG\ExternalDocumentation(
* description="Find out more about store",
* url="http://swagger.io"
* )
* )
*/
/**
* @SWG\SecurityScheme(
* securityDefinition="api_key",
* type="apiKey",
* in="query",
* name="api_key"
* )
*/
/**
* @SWG\SecurityScheme(
* securityDefinition="X-Api-Token",
* type="apiKey",
* in="header",
* name="X-Api-Token"
* )
*/
This is my user controller login function
/**
* Handle a login request to the application.
*
* @SWG\Post(path="/login",
* tags={"User actions"},
* summary="Perform user sign in",
* description="login user using request data",
* produces={"application/json"},
* consumes={"application/json"},
* @SWG\Parameter(
* in="body",
* name="login user",
* description="JSON Object which login user",
* required=true,
* @SWG\Schema(
* type="object",
* @SWG\Property(property="email", type="string", example="[email protected]"),
* @SWG\Property(property="password", type="string", example="password"),
* )
* ),
* @SWG\Response(response="200", description="Return token or error message")
* )
*
* @param Request $request
*
* @return Response
*/
public function login(Request $request){}
I installed "darkaonline/swagger-lume": "5.5.*"
The json is generated as well as config file and view but routes are not working:
/api, /docs
After a lot of searching I was able to get a JSON which when I put in the online swagger editor produce a UI but how to automatically generate a UI component as when I define a route for the swaggers index.php like this
$app->get('/api', function () { return view('vendor.swagger-lume.index'); });
file I get a lot errors like this
(2/2) ErrorExceptionUndefined variable: urlToDocs (View: E:\xampp\htdocs\api\resources\views\vendor\swagger-lume\index.blade.php)
--
I know this is not the exact way but the lack of complete documentation is giving a very hard time.So can you please explain this part how to render the vendor/swagger-lume/index.php
Here is what happens if I try to give the path referred in the config/swagger-lume.php
file.
And of I visit api/documentation here is the error I get
I don't think the generate_always config option is working.
I have mine set to false yet all my swagger docs are available in production.
Hello,
First of all thanks for great work on SwaggerLume
I am trying to use type='object'
in @SWG\Parameter(
and found that type='object'
in not working in swagger 2.0
so i want to change from 2.0
to 3.0
.
i am trying to implement following definition
* @SWG\Parameter(
* name="body",
* in="body",
* description="cart data",
* required=true,
* @SWG\Schema(
* type="object",
* @SWG\Property(
* property="cart",
* type="array",
* @SWG\Items(
* type="object",
* @SWG\Property(property="product_id", type="integer"),
* @SWG\Property(property="amount", type="integer")
* )
* )
* )
* )
* ),
what are the steps to change swagger version ? i am using 2.0
Hi @DarkaOnLine ,
I did the same as per the documentation but I needed HTML output, so that I can share that URL to anyone.
Please suggest me how to convert that JSON response to HTML output.
Thanks.
Hi,
The /api/documentation
route does not send any Content-Type: text/html
header. Thus, some web browser won't display the page as HTML but plain text.
Forcing the header (here https://github.com/DarkaOnLine/SwaggerLume/blob/master/src/Http/Controllers/SwaggerLumeController.php#L59) should fix the issue.
Do you want me to send a PR?
Thanks.
can the author support lumen5.8? thanks
How can I generate json example for specific class?
I've got a lumen running in a docker container and everything seems to work fine except SwaggerLume - for some reason I'm getting the following error and I don't know why - when running in the development version of de image it works but that one doesn't have the app build into it
The annotation "@OpenApi\Annotations\OpenAPI" in /var/www/app/Annotations/Info.php on line 2 does not exist, or could not be auto-loaded
How to install SwaggerLume for Lumen-framework 5.7.*
i got Required @OA\Info() not found
when i run php artisan swagger-lume:generate
best
Hey I try to use parameter type as file but when i check at server side. i am not getting any one. :(
Hi,
How could I handle multiple definitions for my API versions like v1, v2, v3... ?
I'm using different namespaces inside Lumen for each API version, the generation command try to scan everything.. is it not possible generate the definitions based on a folder?
something like:
php artisan swagger-lume:generate ApiV1
php artisan swagger-lume:generate ApiV2
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi, i am trying to use SwaggerLume in the latest version of Lumen and i got this message.
$ php artisan swagger-lume:publish-config
PHP Fatal error: Call to undefined method Laravel\Lumen\Application::share() in
C:\xxyy\vendor\darkaonline\swagger-lume\src\ServiceProvider.php on line 46
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Laravel\Lumen\Application::share()
Next the composer require:
...
"require" : {
"php" : ">=5.6.4",
"laravel/lumen-framework" : "5.4.*",
"vlucas/phpdotenv" : "~2.2",
"darkaonline/swagger-lume" : "1.*"
},
...
Is there any error on my configuration? or the library does not support the latest version of Lumen.
Thanks and best regards.
When i try to publish configuration file by this code
php artisan swagger-lume:publish-config
it reset swagger-lume.php in config folder
i have add this code to header in swagger-lume.php
"request" => [
'APP_VERSION' => '4.0'
],
but after run php artisan swagger-lume:publish-config
it become
/*"request" => [
'TestMe' => 'testValue'
],*/
Just wondering if its possible to update to swagger ui v3, as I would like to make use of the Authorization aspect.
As you know Laravel and Lumen models doesn't have variables from DB Model. We are only defining the table, but not the fields in table.
I need to use this kind of definition for each field, but I don't have fields.
/**
* @var string
* @SWG\Property()
*/
How can I generate User model without fields?
Here is my simple User Model
<?php
namespace App\Models;
use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @SWG\Definition(definition="User", type="object", required={"name"})
*/
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
use Authenticatable, Authorizable, SoftDeletes;
protected $table='user';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'surname', 'email',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
];
}
Installed packages :
"php": ">=5.6.4",
"laravel/lumen-framework": "5.4.",
"vlucas/phpdotenv": "2.4.0",
"illuminate/redis": "5.4.",
"palanik/lumen-cors": "dev-master",
"giggsey/libphonenumber-for-php": "^8.8",
"darkaonline/swagger-lume": "~3.0"
withFacades is active, Service provider is registered, swaggerlume is configured in bootstrap.
All seems working except the controller with assets :
http://localhost:8000/swagger-ui-assets/swagger-ui.css return a templated page with :
The requested resource /swagger-ui-assets/swagger-ui.css was not found on this server.
Same thing with js files.
Hi,
Your package is fantastic, I'm currently using it to document a Lumen-driven API. Quick question, I'd like to dynamically define the host
value in @SWG\Swagger
. The swagger-php documentation mentions this is possible by first defining a constant:
However to do so the documentation mentions passing along a constants.php
file. Is there some way to dynamically update annotations using SwaggerLume?
Thank you!
Hi guys,
1- REPORT ERROR:
I use your library and apprance issue:
'auth_token' config default value is 'false'. But I want to default value isn't false => Error javascript in index.blade.php
- File: /resources/views/vender/swagger-lume/index.blade.php
- Line: window.swaggerUi.api.clientAuthorizations.add("{{$apiKeyVar}}", apiKeyAuth);
- Description error: documentation:86 Uncaught TypeError: Cannot read property 'clientAuthorizations' of null
- Because: window.swaggerUi don't loaded
- Fix: Move window.swaggerUi.load(); before function addApiKeyAuthorization(). Cause: first window.swaggerUi, second call function addApiKeyAuthorization()
2- FEEDBACK FEATURE
I use oauth2, normal key will add prefix (BEAERER, BASIC....)
Update:
if(key && key.trim() != "") { var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("{{$apiKeyVar}}",{{$apiPrefixKeyVar}} + key, "{{$apiKeyInject}}"); window.swaggerUi.api.clientAuthorizations.add("{{$apiKeyVar}}", apiKeyAuth); }
Thanks
I would love to be-able to hide the shown fields and pre-fill them with the client_id and client_secret defined in my .env file and also default the client credentials location to body.
Is this possible?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi,
when i try to generate the docs I get the exception
[ErrorException]
Field "schema" is required when @SWG\Parameter(name="body",in="body") is in
"body" in \App\Http\Controllers\AccessLogController->create_login_log() in
/Users/dev/Documents/others/winkerapp-api/app/Http/Controllers/AccessLogCo
ntroller.php on line 30
/**
* @SWG\Post(
* path="/api/access/login",
* consumes={"application/json"},
* description="Create a loggin log",
* operationId="logloggin",
* @SWG\Parameter(
* description="user id",
* in="body",
* name="user_id",
* required=true,
* type="integer"
* ),
* @SWG\Response(
* response="200",
* description="successful operation",
* @SWG\Schema(ref="#/definitions/AccessLog")
* ),
* summary="register a loggin log",
* tags={
* "log"
* }
* )
* */
Hello,
[Tue Jul 24 17:44:39 2018] ::1:57133 [200]: /api/documentation [Tue Jul 24 17:44:39 2018] ::1:57136 [404]: /swagger-ui-assets/swagger-ui.css?v=5a547f5645edb0cf963a796f34eed06b - No such file or directory [Tue Jul 24 17:44:39 2018] ::1:57137 [404]: /swagger-ui-assets/swagger-ui-bundle.js?v=3d68d211488eba1178503308e70caabc - No such file or directory [Tue Jul 24 17:44:39 2018] ::1:57138 [404]: /swagger-ui-assets/swagger-ui-standalone-preset.js?v=c30a2a12a47f2c4ca81b3cb7076a31bf - No such file or directory [Tue Jul 24 17:44:39 2018] ::1:57139 [404]: /swagger-ui-assets/swagger-ui-standalone-preset.js?v=c30a2a12a47f2c4ca81b3cb7076a31bf - No such file or directory
when i try to access to api/documentation
i get in the console this error i sent
i use Lumen (5.6.4) (Laravel Components 5.6.*)
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Hi, great package! Thanks a lot for publishing it.
One thing I've noticed about the README:
composer require "darkaonline/swagger-lume ~1.0"
throws the error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package darkaonline/swagger-lume could not be found in any version, there may be a typo in the package name.
Using dev-master it works:
composer require darkaonline/swagger-lume:dev-master
Might be worth mentioning that in the README file or create a 1.0 version so the mentioned command line would work.
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.