agrodata / laravel-data-openapi-generator
Generate OpenAPI specification from Laravel routes and Laravel Data objects.
0.3
2025-01-16 20:53 UTC
Requires
- laravel/framework: ^8|^9|^10|^11
- phpdocumentor/reflection-docblock: ^5.4
- spatie/invade: ^2
- spatie/laravel-data: ^4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- nunomaduro/larastan: ^2.9
- orchestra/testbench: ^9
- pestphp/pest: ^v2.34
This package is not auto-updated.
Last update: 2025-01-31 19:05:48 UTC
README
Generate OpenAPI specification from Laravel routes and Laravel Data objects
Install
Add composer repository
In composer.json
add this repository:
"repositories": [
{
"type": "github",
"url": "https://github.com/xolvionl/laravel-data-openapi-generator"
}
],
Install
composer require xolvio/laravel-data-openapi-generator
Optional
Version
Add a app.version
config in app.php
to set the version in the openapi specification:
'version' => env('APP_VERSION', '1.0.0'),
Vite PWA config
If using vite-plugin-pwa
, make sure to exclude '/api/' routes from the serviceworker using this config:
VitePWA({
workbox: {
navigateFallbackDenylist: [
new RegExp('/api/.+'),
],
},
})
Vue page
<route lang="json">
{
"meta": {
"public": true
}
}
</route>
<template>
<iframe
:src="url"
style="width: calc(100vw - 40px);height: calc(100vh - 80px); border: none;"
/>
</template>
<script lang="ts" setup>
const url = `${import.meta.env.VITE_APP_URL}/api/openapi`;
</script>
Usage
Config
php artisan vendor:publish --tag=openapi-generator-config
Generate
php artisan openapi:generate
View
Swagger available at APP_URL/api/openapi