public function parseSchema(string $openApiSpecPath): OpenApi
    {
        $openApiSpecContents = file_get_contents($openApiSpecPath);
        $jsonException = null;
        $yamlException = null;

        try {
            return $this->deserialize($openApiSpecContents, $openApiSpecPath);
        } catch (\Exception $exception) {
            $jsonException = $exception;
        }

        try {
            $content = Yaml::parse(
                $openApiSpecContents,
                Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_DATETIME | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE
            );

            return $this->denormalize($content, $openApiSpecPath);
        } catch (YamlException $yamlException) {
            throw new \LogicException(sprintf(
                "Could not parse schema in JSON nor YAML format:\n- JSON error: \"%s\"\n- YAML error: \"%s\"\n",
                $jsonException->getMessage(),
                $yamlException->getMessage()
            ));
        }
    }
public function parseSchema(string $openApiSpecPath): OpenApi
    {
        $openApiSpecContents = file_get_contents($openApiSpecPath);
        $jsonException = null;
        $yamlException = null;

        try {
            return $this->deserialize($openApiSpecContents, $openApiSpecPath);
        } catch (\Exception $exception) {
            $jsonException = $exception;
        }

        try {
            $content = Yaml::parse(
                $openApiSpecContents,
                Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_DATETIME | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE
            );

            return $this->denormalize($content, $openApiSpecPath);
        } catch (YamlException $yamlException) {
            throw new \LogicException(sprintf(
                "Could not parse schema in JSON nor YAML format:\n- JSON error: \"%s\"\n- YAML error: \"%s\"\n",
                $jsonException->getMessage(),
                $yamlException->getMessage()
            ));
        }
    }
public function parseSchema ( string $ openApiSpecPath ) : OpenApi { $ openApiSpecContents = file_get_contents ( $ openApiSpecPath ) ; $ jsonException = null ; $ yamlException = null ; try { return $ this -> deserialize ( $ openApiSpecContents , $ openApiSpecPath ) ; } catch ( \ Exception $ exception ) { $ jsonException = $ exception ; } try { $ content = Yaml :: parse ( $ openApiSpecContents , Yaml :: PARSE_OBJECT | Yaml :: PARSE_OBJECT_FOR_MAP | Yaml :: PARSE_DATETIME | Yaml :: PARSE_EXCEPTION_ON_INVALID_TYPE ) ; return $ this -> denormalize ( $ content , $ openApiSpecPath ) ; } catch ( YamlException $ yamlException ) { throw new \ LogicException ( sprintf ( "Could not parse schema in JSON nor YAML format:\n- JSON error: \"%s\"\n- YAML error: \"%s\"\n" , $ jsonException -> getMessage ( ) , $ yamlException -> getMessage ( ) ) ) ; } }
Parse an file into a OpenAPI Schema model.
Parse an file into a OpenAPI Schema model .