From 9b5c2d5390c9b8ada7685c9b1496395a68318a74 Mon Sep 17 00:00:00 2001 From: Oh My Felix Date: Mon, 22 Jun 2026 18:51:55 +0000 Subject: [PATCH 1/2] Docs: move documentation to README Co-authored-by: Felix --- .docs/README.md | 67 ---------------------------------------------- README.md | 70 +++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 78 deletions(-) delete mode 100644 .docs/README.md diff --git a/.docs/README.md b/.docs/README.md deleted file mode 100644 index 52fc6e6..0000000 --- a/.docs/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Contributte OpenApi - -Pure PHP OpenAPI 3.0 implementation for Nette Framework. - -## Content - -- [Setup](#setup) -- [OpenAPI](#tracy) -- [Tracy](#tracy) - -## Setup - -Install package - -```bash -composer require contributte/openapi -``` - -## OpenAPI - -- [Callback.php](../src/Schema/Callback.php) -- [Components.php](../src/Schema/Components.php) -- [Contact.php](../src/Schema/Contact.php) -- [Example.php](../src/Schema/Example.php) -- [ExternalDocumentation.php](../src/Schema/ExternalDocumentation.php) -- [Header.php](../src/Schema/Header.php) -- [Info.php](../src/Schema/Info.php) -- [License.php](../src/Schema/License.php) -- [Link.php](../src/Schema/Link.php) -- [MediaType.php](../src/Schema/MediaType.php) -- [OAuthFlow.php](../src/Schema/OAuthFlow.php) -- [OpenApi.php](../src/Schema/OpenApi.php) -- [Operation.php](../src/Schema/Operation.php) -- [Parameter.php](../src/Schema/Parameter.php) -- [PathItem.php](../src/Schema/PathItem.php) -- [Paths.php](../src/Schema/Paths.php) -- [Reference.php](../src/Schema/Reference.php) -- [RequestBody.php](../src/Schema/RequestBody.php) -- [Response.php](../src/Schema/Response.php) -- [Responses.php](../src/Schema/Responses.php) -- [Schema.php](../src/Schema/Schema.php) -- [SecurityRequirement.php](../src/Schema/SecurityRequirement.php) -- [SecurityScheme.php](../src/Schema/SecurityScheme.php) -- [Server.php](../src/Schema/Server.php) -- [ServerVariable.php](../src/Schema/ServerVariable.php) -- [Tag.php](../src/Schema/Tag.php) - -## Tracy - -![](misc/tracy-panel.png) - -```neon -services: - swaggerPanel: - class: Contributte\OpenApi\Tracy\SwaggerPanel() - setup: - - setSpec([...openapi]) - - setLazySpec([@openapi, getSpec]) - - setUrl('https://petstore.swagger.io/v2/swagger.json') - - setExpansion() - - setFilter("role=User") - - setTitle(MyAPI) - -tracy: - bar: - - @swaggerPanel -``` diff --git a/README.md b/README.md index d762ffd..fbf68a5 100644 --- a/README.md +++ b/README.md @@ -12,36 +12,84 @@ -

+

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

-## Usage +Pure PHP OpenAPI 3.0 implementation for Nette Framework. + +## Versions + +| State | Version | Branch | Nette | PHP | +|--------|---------|----------|-------|---------| +| dev | `^0.2` | `master` | 4.0+ | `>=8.2` | +| stable | `^0.1` | `master` | 4.0+ | `>=8.1` | + +## Installation To install the latest version of `contributte/openapi` use [Composer](https://getcomposer.org). -``` +```bash composer require contributte/openapi ``` -## Documentation +## OpenAPI + +- [Callback.php](src/Schema/Callback.php) +- [Components.php](src/Schema/Components.php) +- [Contact.php](src/Schema/Contact.php) +- [Example.php](src/Schema/Example.php) +- [ExternalDocumentation.php](src/Schema/ExternalDocumentation.php) +- [Header.php](src/Schema/Header.php) +- [Info.php](src/Schema/Info.php) +- [License.php](src/Schema/License.php) +- [Link.php](src/Schema/Link.php) +- [MediaType.php](src/Schema/MediaType.php) +- [OAuthFlow.php](src/Schema/OAuthFlow.php) +- [OpenApi.php](src/Schema/OpenApi.php) +- [Operation.php](src/Schema/Operation.php) +- [Parameter.php](src/Schema/Parameter.php) +- [PathItem.php](src/Schema/PathItem.php) +- [Paths.php](src/Schema/Paths.php) +- [Reference.php](src/Schema/Reference.php) +- [RequestBody.php](src/Schema/RequestBody.php) +- [Response.php](src/Schema/Response.php) +- [Responses.php](src/Schema/Responses.php) +- [Schema.php](src/Schema/Schema.php) +- [SecurityRequirement.php](src/Schema/SecurityRequirement.php) +- [SecurityScheme.php](src/Schema/SecurityScheme.php) +- [Server.php](src/Schema/Server.php) +- [ServerVariable.php](src/Schema/ServerVariable.php) +- [Tag.php](src/Schema/Tag.php) -For details on how to use this package, check out our [documentation](.docs). +## Tracy -## Version +![](.docs/misc/tracy-panel.png) -| State | Version | Branch | Nette | PHP | -|-------------|---------|----------|------|---------| -| dev | `^0.2` | `master` | 4.0+ | `>=8.2` | -| stable | `^0.1` | `master` | 4.0+ | `>=8.1` | +```neon +services: + swaggerPanel: + class: Contributte\OpenApi\Tracy\SwaggerPanel() + setup: + - setSpec([...openapi]) + - setLazySpec([@openapi, getSpec]) + - setUrl('https://petstore.swagger.io/v2/swagger.json') + - setExpansion() + - setFilter("role=User") + - setTitle(MyAPI) + +tracy: + bar: + - @swaggerPanel +``` ## Development See [how to contribute](https://contributte.org/contributing.html) to this package. -This package is currently maintaining by these authors. +This package is currently maintained by these authors. From 6b893eb1d68bcb1dd1a2605569598191de688255 Mon Sep 17 00:00:00 2001 From: Oh My Felix Date: Tue, 7 Jul 2026 17:04:40 +0000 Subject: [PATCH 2/2] Docs: polish README migration --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index fbf68a5..ba0d516 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,37 @@ To install the latest version of `contributte/openapi` use [Composer](https://ge composer require contributte/openapi ``` +## Usage + +Create a document with schema objects and export it through `toArray()`. + +```php +use Contributte\OpenApi\Schema\Info; +use Contributte\OpenApi\Schema\OpenApi; +use Contributte\OpenApi\Schema\Operation; +use Contributte\OpenApi\Schema\PathItem; +use Contributte\OpenApi\Schema\Paths; +use Contributte\OpenApi\Schema\Response; +use Contributte\OpenApi\Schema\Responses; + +$responses = new Responses(); +$responses->setResponse('200', new Response('OK')); + +$operation = new Operation($responses); +$operation->setSummary('List users'); + +$path = new PathItem(); +$path->setOperation(PathItem::OPERATION_GET, $operation); + +$paths = new Paths(); +$paths->setPathItem('/users', $path); + +$openApi = new OpenApi('3.0.3', new Info('My API', '1.0.0'), $paths); + +header('Content-Type: application/json'); +echo json_encode($openApi->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); +``` + ## OpenAPI - [Callback.php](src/Schema/Callback.php)