/** * @param string $filePath * @return RamlDoc */ public function parse($filePath) { $rawRaml = Yaml::parse($filePath); $ramlDoc = new RamlDoc($rawRaml, $filePath); foreach (RamlSpec::$rootLevelDeclarations as $key) { if (isset($rawRaml[$key])) { $ramlDoc->{$key} = $this->mapCollectionParser->parse($key, $rawRaml[$key], $ramlDoc); } } $this->docExpander->expand($ramlDoc); return $ramlDoc; }
public function testParsingMapCollection() { /* Given... (Fixture) */ $jsonCoder = Stub::makeEmpty('GoIntegro\\Json\\JsonCoder'); $path = __DIR__ . self::RAML_PATH; $ramlDoc = Stub::makeEmpty('GoIntegro\\Raml\\RamlDoc', ['fileDir' => dirname($path), 'rawRaml' => Yaml::parse($path)]); $raw = ['!include some-traits.yml', ['secured' => '!include some-trait.yml'], ['paged' => ['queryParameters' => ['start' => ['type' => 'number']]]], ['searchable' => ['queryParameters' => ['query' => ['type' => 'string']]]]]; $parser = new MapCollectionParser($jsonCoder); /* When... (Action) */ $mapCollection = $parser->parse('traits', $raw, $ramlDoc); /* Then... (Assertions) */ $this->assertInstanceOf('GoIntegro\\Raml\\Root\\MapCollection', $mapCollection); }