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.
You'll need to install:
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.
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/
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.