Ejemplo n.º 1
0
 /**
  * @depends testNavigatingARaml
  */
 public function testFindingInlineBodySchema()
 {
     /* Given... (Fixture) */
     $jsonCoder = Stub::makeEmpty('GoIntegro\\Json\\JsonCoder');
     $ramlDoc = Stub::makeEmpty('GoIntegro\\Raml\\RamlDoc', ['rawRaml' => Yaml::parse(__DIR__ . self::INLINE_BODY_SCHEMA_RAML), 'schemas' => Stub::makeEmpty('GoIntegro\\Raml\\Root\\MapCollection')]);
     $navigator = new DocNavigator($ramlDoc, $jsonCoder);
     /* When... (Action) */
     $schema = $navigator->findRequestSchema(RamlSpec::HTTP_POST, '/some-resources');
     /* Then... (Assertions) */
     $this->assertEquals(self::INLINE_BODY_SCHEMA, $schema);
 }
Ejemplo n.º 2
0
 /**
  * @param Params $params
  * @param string $method
  * @return \stdClass
  * @throws Raml\MissingSchemaException
  * @throws Raml\MalformedSchemaException
  */
 protected function findResourceObjectSchema(Params $params, $method)
 {
     $jsonSchema = $this->docNavigator->findRequestSchema($method, '/' . $params->primaryType);
     if (empty($jsonSchema)) {
         $message = sprintf(self::ERROR_MISSING_SCHEMA, $params->primaryType);
         throw new Raml\MissingSchemaException($message);
     } elseif (empty($jsonSchema->properties->{$params->primaryType})) {
         $message = sprintf(self::ERROR_MALFORMED_SCHEMA, $params->primaryType);
         throw new Raml\MalformedSchemaException($message);
     }
     // @todo Move. (To method? To DocNav?)
     return $jsonSchema->properties->{$params->primaryType};
 }