1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package gov.nist.secauto.metaschema.schemagen.json.impl;
7
8 import com.fasterxml.jackson.databind.node.ObjectNode;
9
10 import edu.umd.cs.findbugs.annotations.NonNull;
11
12 /**
13 * Represents a JSON schema for a given Metaschema-based model object, which may
14 * be part of a larger JSON schema.
15 */
16 @FunctionalInterface
17 public interface IJsonSchema {
18
19 /**
20 * Generate an inline JSON schema.
21 *
22 * @param node
23 * the property JSON object
24 * @param state
25 * the schema generation state used for context
26 */
27 void generateInlineJsonSchema(@NonNull ObjectNode node, @NonNull IJsonGenerationState state);
28
29 /**
30 * Generate a JSON schema or a reference to a JSON schema definition.
31 * <p>
32 * This method will determine if this schema is intended to be inline or used as
33 * a JSON schema definition by reference.
34 *
35 * @param node
36 * the property JSON object
37 * @param state
38 * the schema generation state used for context
39 */
40 default void generateJsonSchemaOrDefinitionRef(@NonNull ObjectNode node, @NonNull IJsonGenerationState state) {
41 generateInlineJsonSchema(node, state);
42 }
43
44 /**
45 * Determine if the schema is defined inline or as a global definition.
46 *
47 * @param state
48 * the schema generation state used for context
49 * @return {@code true} if the schema is to be defined inline or {@code false}
50 * if the schema is to be defined globally
51 */
52 default boolean isInline(@NonNull IJsonGenerationState state) {
53 return true;
54 }
55 }