Raml\Parser::parse PHP Method

parse() public method

Parse a RAML spec from a file
public parse ( string $rawFileName ) : ApiDefinition
$rawFileName string
return ApiDefinition
    public function parse($rawFileName)
    {
        $fileName = realpath($rawFileName);
        if (!is_file($fileName)) {
            throw new FileNotFoundException($rawFileName);
        }
        $rootDir = dirname($fileName);
        $ramlString = file_get_contents($fileName);
        $ramlData = $this->parseRamlString($ramlString, $rootDir);
        return $this->parseRamlData($ramlData, $rootDir);
    }

Usage Example

 /** @test */
 public function shouldReturnAnArrayOfTypes()
 {
     $apiDefinition = $this->parser->parse(__DIR__ . '/fixture/multipleTypes.raml');
     $resource = $apiDefinition->getResourceByUri('/');
     $method = $resource->getMethod('post');
     $body = $method->getBodyByType('application/x-www-form-urlencoded');
     $this->assertInstanceOf('\\Raml\\WebFormBody', $body);
 }
All Usage Examples Of Raml\Parser::parse