purplebooth / jane-open-api-autogenerate
This is a plugin for composer that allows you to generate a client from a given swagger definition
Installs: 15 689
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 7
Open Issues: 2
Type:composer-plugin
Requires
- composer-plugin-api: ^1.0
- jane/open-api: ^1.2.0
- jane/openapi-runtime: ^1.0
- nikic/php-parser: ^2.1.0
Requires (Dev)
This package is not auto-updated.
Last update: 2020-06-12 19:13:40 UTC
README
This project is designed to allow you to add an automatically generated OpenAPI (swagger) client as a dependency via a composer dependency.
This project uses jane/open-api.
Getting Started
Prerequisities
You'll need to install:
- PHP (Minimum 5.6)
Usage
You have a few options, you could add to the repository you keep your swagger definition define a composer.json that looks something like this.
{ "name": "swagger/petstore", "type": "swagger-api", "extra": { "namespace": "Swagger\\Petstore", "schema-file": "swagger.json" }, "autoload": { "psr-4": { "Swagger\\Petstore\\": "generated/" } }, "require": { "purplebooth/jane-open-api-autogenerate": "^0.1.4" } }
and then run
$ composer require swagger/petstore
alternatively you could add the package manually in the composer.json
{ "require": { "swagger/petstore": "0.1.0", "purplebooth/jane-open-api-autogenerate": "" }, "repositories": [{ "type": "package", "package": { "autoload": { "psr-4": { "Swagger\\Petstore\\": "generated/" } }, "type": "swagger-api", "name": "swagger/petstore", "version": "0.1.0", "extra": { "namespace": "Swagger\\Petstore", "schema-file": "/path/to/swagger.json" }, "require": { "purplebooth/jane-open-api-autogenerate": "v0.1.4" }, "dist" : { "type": "path", "url": "/path/to/swagger.json" } } }] }
You do not need to provide a dist/source directory if we're not checking out your swagger.json from somewhere.
{ "require": { "swagger/petstore": "0.1.0", "purplebooth/jane-open-api-autogenerate": "" }, "repositories": [{ "type": "package", "package": { "autoload": { "psr-4": { "Swagger\\Petstore\\": "generated/" } }, "type": "swagger-api", "name": "swagger/petstore", "version": "0.1.0", "extra": { "namespace": "Swagger\\Petstore", "schema-file": "http://example/path/to/swagger.json" }, "require": { "purplebooth/jane-open-api-autogenerate": "v0.1.4" } } }] }
Another feature of this library is the ability to override the swagger file from a location defined by an environment variable. To do this you simply define an additional key in the package specifies in which environment variable.
"extra": { "namespace": "Swagger\\Petstore\\", "schema-file": "/path/to/swagger.json", "environment-variable": "PETS_SWAGGER_YAML" },
If it's not set it'll fall back to the value defined in the schema-file attribute.
Coding Style
We follow PSR2, and also enforce PHPDocs on all functions. To run the tests for coding style violations
vendor/bin/phpcs -p --standard=psr2 src/
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
See the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.