Parse and generate API specification formats

v2.1.0 2017-05-07 18:41 UTC



Currently there are several API specification formats (RAML, Swagger, etc.) which describe the functionality of an API endpoint. This project provides a data model which contains the common informations of an API endpoint. There are parser classes which create such models based on a specification and it is also possible to generate a specification from a model object.


  • RAML (RAML 0.8 specification)
  • Annotation (Parses a class which contains annotations)


  • RAML (Generates a RAML 0.8 specification)
  • JsonSchema (Generates a JsonSchema which contains all schemas of the specification)
  • Swagger (Generates a Swagger 1.2 specification)
  • WSDL (Generates a WSDL 1.1 specification)
  • XSD (Generates a XSD which contains all schemas of the specification)


The root model object is called resource which represents a specific API endpoint. The following is a simple showcase of the resource API so you get a basic understanding how it is designed.


// reads the RAML specification and generates a resource object which was
// defined under the path /foo
$resource = Raml::fromFile('spec.raml', '/foo');

// returns the title

// returns available path parameters as PSX\Schema\SchemaInterface

// checks whether a specific request method is supported

// returns all allowed methods

// returns the available query parameters per method as PSX\Schema\SchemaInterface

// checks whether the method has a request specification

// returns the request body specification as PSX\Schema\SchemaInterface

// checks whether the method has a response with the status code 201

// returns the response body specification as PSX\Schema\SchemaInterface

// creates a new WSDL generator and generate a WSDL representation of this
// resource
$generator = new Generator\Wsdl('foo', '', '');

$wsdl = $generator->generate($resource);


The following list contains generator and parser classes which we want to support in the near future. In case you want to support a different format do not hesitate to open an issue or pull request.