Ejemplo n.º 1
0
 /**
  * Return a list of class guessed
  *
  * @param $swaggerSpec
  * @param $name
  * @param $namespace
  * @param $directory
  *
  * @return Context
  */
 public function createContext($swaggerSpec, $name, $namespace, $directory)
 {
     $schema = $this->serializer->deserialize(file_get_contents($swaggerSpec), Swagger::class, 'json');
     $classes = $this->chainGuesser->guessClass($schema, $name);
     foreach ($classes as $class) {
         $properties = $this->chainGuesser->guessProperties($class->getObject(), $name, $classes);
         foreach ($properties as $property) {
             $property->setType($this->chainGuesser->guessType($property->getObject(), $property->getName(), $classes));
         }
         $class->setProperties($properties);
     }
     return new Context($schema, $namespace, $directory, $classes);
 }
Ejemplo n.º 2
0
 public static function create(SerializerInterface $serializer)
 {
     $naming = new Naming();
     $resolver = new Resolver($serializer);
     $chainGuesser = new ChainGuesser();
     $chainGuesser->addGuesser(new ReferenceGuesser($resolver));
     $chainGuesser->addGuesser(new SwaggerGuesser());
     $chainGuesser->addGuesser(new SchemaGuesser($naming, $resolver));
     $chainGuesser->addGuesser(new AdditionalPropertiesGuesser());
     $chainGuesser->addGuesser(new AllOfGuesser($resolver));
     $chainGuesser->addGuesser(new ArrayGuesser());
     $chainGuesser->addGuesser(new ItemsGuesser());
     $chainGuesser->addGuesser(new SimpleTypeGuesser());
     $chainGuesser->addGuesser(new MultipleGuesser());
     return $chainGuesser;
 }