Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenAPI docs #1

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/public/api/assets/bundles
/var/
/vendor/
###< symfony/framework-bundle ###
Expand All @@ -26,7 +26,3 @@ phpstan.neon
/phpunit.xml
###< symfony/phpunit-bridge ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###
5 changes: 4 additions & 1 deletion backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.54",
"nelmio/api-doc-bundle": "^4.26",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^11.1",
"symfony/asset": "6.4.*",
"symfony/browser-kit": "6.4.*",
"symfony/css-selector": "6.4.*",
"symfony/debug-bundle": "6.4.*",
"symfony/phpunit-bridge": "^7.0",
"symfony/stopwatch": "6.4.*",
"symfony/twig-bundle": "6.4.*",
"symfony/web-profiler-bundle": "6.4.*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
"assets:install %PUBLIC_DIR%/api/assets": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
Expand Down
267 changes: 266 additions & 1 deletion backend/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['dev' => true],
];
3 changes: 3 additions & 0 deletions backend/config/packages/dev/assets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
assets:
base_path: /api/assets
11 changes: 11 additions & 0 deletions backend/config/packages/dev/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
nelmio_api_doc:
html_config:
assets_mode: cdn
documentation:
info:
title: Flexhub
description: Private storage for symfony/flex recipes
version: 0.x.x
areas: # to filter documented areas
path_patterns:
- ^\/api(?!\/doc$|\/_wdt\/|\/_profiler\/) # Accepts routes under /api except /api/doc, /api/_wdt/*, /api/_profiler/*
12 changes: 12 additions & 0 deletions backend/config/routes/dev/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Expose your documentation as JSON swagger compliant
app.swagger:
path: /api/doc.json
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger }

## Requires the Asset component and the Twig bundle
## $ composer require twig asset
app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
Empty file.
2 changes: 2 additions & 0 deletions backend/src/Controller/Api/FlexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Controller\Api;

use App\Flex\Index\IndexLoaderInterface;
use OpenApi\Attributes as OA;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -13,6 +14,7 @@
* @phpstan-import-type FlexIndex from IndexLoaderInterface
*/
#[Route('/flex')]
#[OA\Tag('Flex')]
final class FlexController extends AbstractController
{
/** @return FlexIndex */
Expand Down
Loading