All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eel.kitchen.jsonschema.schema.AddressingMode Maven / Gradle / Ivy

There is a newer version: 1.5.2
Show newest version
/*
 * Copyright (c) 2012, Francis Galiegue 
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

package org.eel.kitchen.jsonschema.schema;

import com.fasterxml.jackson.databind.JsonNode;

import java.net.URI;

/**
 * Schema addressing mode
 *
 * 

JSON Schema defines the {@code id} keyword for schema identification * purposes. This keyword can be used both at the schema root and in * subschemas. For instance:

* *
 *     {
 *         "id": "some://where/schema.json",
 *         "sub": {
 *             "id": "other.json"
 *         }
 *     }
 * 
* *

What can happen here is that an implementation walks the schema and * determines that the URI of the root schema is {@code some://where/schema.json * }, which is pretty much normal. It can also see the other {@code id} * in subschema {@code /sub} and resolve the value of this subschema against the * root URI: this gives {@code some://where/other.json}. This is called by this * implementation {@link #INLINE} addressing mode.

* *

By default, for security reasons, the addressing mode is {@link #CANONICAL * }.

*/ public enum AddressingMode { CANONICAL { @Override public SchemaContainer forSchema(final URI uri, final JsonNode schema) { return new CanonicalSchemaContainer(uri, schema); } }, INLINE { @Override public SchemaContainer forSchema(final URI uri, final JsonNode schema) { return new InlineSchemaContainer(schema); } }; private static final URI EMPTY = URI.create("#"); public abstract SchemaContainer forSchema(final URI uri, final JsonNode schema); public final SchemaContainer forSchema(final JsonNode schema) { return forSchema(EMPTY, schema); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy