howyi / lamb
Generate API docs from JSON Schema
v0.0.1
2017-09-03 08:48 UTC
Requires
- php: >=7.0.16
- howyi/evi: ^0.9.0
- symfony/console: ~2.0 | ~3.0
- symfony/yaml: ~2.0 | ~3.0
Requires (Dev)
- phpspec/prophecy: ^1.7
- phpstan/phpstan: ^0.8.0
- phpunit/phpunit: ^6.2
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: ^3.0
- symfony/var-dumper: ^3.3
This package is auto-updated.
Last update: 2025-01-25 20:43:23 UTC
README
lamb
JSON Schema(&YAML) extension & API document generator
Usable API
Quickstart
Install
composer require howyi/lamb
Config
Put lamb.yml
in current working directory
name: LambTestAPI version: 1.0.0 path: collection: sample/collection environment: sample/environment request: sample/request scenario: sample/scenario environment: host: https://example.com/v2 default: request: header: sessionKey: value: ((sessionKey)) parameter: # sessionKey: # required: true # value: ((sessionKey))
API format
YAML
sample/collection/account/settings.yml
API endpoint: https://example.com/v2/account/settings
POST: description: Updates user's settings. request: body: $schema: http://json-schema.org/draft-04/schema# type: object properties: language: title: user's language type: string age: title: age type: integer additionalProperties: true required: [] response: body: $schema: http://json-schema.org/draft-04/schema# type: object properties: language: title: user's language type: string age: title: age type: integer additionalProperties: true required: [language, age]
JSON
sample/collection/account/update_profile.json
API endpoint: https://example.com/v2/account/update_profile
{ "POST": { "description": "Updates user's profile.", "request": { "body": { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "language": { "title": "user's language", "type": "string" }, "age": { "title": "age", "type": "integer" } }, "additionalProperties": true, "required" : [] } }, "response": { "body": { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "language": { "title": "user's language", "type": "string" }, "age": { "title": "age", "type": "integer" } }, "additionalProperties": true, "required" : ["language", "age"] } } } }
Environment format
YAML
sample/environment/sample_env.yml
sessionKey: hogehogehogehoge
JSON
{ "sessionKey": "hogehogehogehoge" }
Generate POSTMAN Collection
$collection = \Lamb\CollectionStructureFactory::fromDir(); dump(\Lamb\Converter\Postman::collection($collection)); $environment = \Lamb\EnvironmentStructureFactory::fromDir(); dump(\Lamb\Converter\Postman::environment($environment));
Generate Swagger document
$collection = \Lamb\CollectionStructureFactory::fromDir(); $environment = \Lamb\EnvironmentStructureFactory::fromDir(); dump(\Lamb\Converter\Swagger::document($collection, $environment, 'your_env'));
Generate API Blueprint document
$collection = \Lamb\CollectionStructureFactory::fromDir(); dump(\Lamb\Converter\ApiBlueprint::document($collection));
Generate RAML document
$collection = \Lamb\CollectionStructureFactory::fromDir(); $environment = \Lamb\EnvironmentStructureFactory::fromDir(); dump(\Lamb\Converter\Raml::document($collection, $environment, 'your_env'));