folly/folly/json/JSONSchema.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/json/JSONSchema.h>

#include <boost/algorithm/string/replace.hpp>
#include <boost/regex.hpp>

#include <folly/CPortability.h>
#include <folly/Conv.h>
#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/Singleton.h>
#include <folly/String.h>
#include <folly/json/json.h>
#include <folly/portability/Math.h>

namespace folly {
namespace jsonschema {

namespace {

/**
 * We throw this exception when schema validation fails.
 */
struct FOLLY_EXPORT SchemaError : std::runtime_error {};

template <class... Args>
Optional<SchemaError> makeError(Args&&... args) {}

struct ValidationContext;

struct IValidator {};

/**
 * This is a 'context' used only when executing the validators to validate some
 * json. It keeps track of which validators have been executed on which json so
 * we can detect infinite recursion.
 */
struct ValidationContext {};

/**
 * This is a 'context' used only when building the schema validators from a
 * piece of json. It stores the original schema and the set of refs, so that we
 * can have parts of the schema refer to other parts.
 */
struct SchemaValidatorContext final {};

/**
 * Root validator for a schema.
 */
struct SchemaValidator final : IValidator, public Validator {};

struct MultipleOfValidator final : IValidator {};

struct ComparisonValidator final : IValidator {};

template <class Comparison>
struct SizeValidator final : IValidator {};

struct StringPatternValidator final : IValidator {};

struct ArrayUniqueValidator final : IValidator {};

struct ArrayItemsValidator final : IValidator {};

struct RequiredValidator final : IValidator {};

struct PropertiesValidator final : IValidator {};

struct DependencyValidator final : IValidator {};

struct EnumValidator final : IValidator {};

struct TypeValidator final : IValidator {};

struct AllOfValidator final : IValidator {};

struct AnyOfValidator final : IValidator {};

struct RefValidator final : IValidator {};

struct NotValidator final : IValidator {};

void SchemaValidator::loadSchema(
    SchemaValidatorContext& context, const dynamic& schema) {}

void SchemaValidator::validate(const dynamic& value) const {}

exception_wrapper SchemaValidator::try_validate(
    const dynamic& value) const noexcept {}

Optional<SchemaError> SchemaValidator::validate(
    ValidationContext& vc, const dynamic& value) const {}

/**
 * Metaschema, i.e. schema for schema.
 * Inlined from the $schema url
 */
const char* metaschemaJson =;

folly::Singleton<Validator> schemaValidator([]() {});
} // namespace

Validator::~Validator() = default;

std::unique_ptr<Validator> makeValidator(const dynamic& schema) {}

std::shared_ptr<Validator> makeSchemaValidator() {}
} // namespace jsonschema
} // namespace folly