Remove identity from OpenAPI Schemas 99/107899/13
authorSamuel Schneider <samuel.schneider@pantheon.tech>
Tue, 10 Oct 2023 10:45:41 +0000 (12:45 +0200)
committerSamuel Schneider <samuel.schneider@pantheon.tech>
Tue, 17 Oct 2023 12:50:44 +0000 (14:50 +0200)
Removes creation of schemas for identity. Use string
value instead of reference on this schema.

Adds test for new behavior.

JIRA: NETCONF-1145
Change-Id: Ic1118bdb90649aa123caa642f06cd00e966e808d
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/DefinitionGenerator.java
restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/DefinitionGeneratorTest.java
restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040Test.java
restconf/restconf-openapi/src/test/resources/openapi-document/controller-all.json
restconf/restconf-openapi/src/test/resources/openapi-document/controller-toaster.json
restconf/restconf-openapi/src/test/resources/openapi-document/device-all.json
restconf/restconf-openapi/src/test/resources/openapi-document/device-toaster.json

index 3e447d9683cd04a3e4f8cd7cca7f3b6f83a31106..e9be71f75e59710a20ebe50b567680a54ebad413 100644 (file)
@@ -124,8 +124,6 @@ public final class DefinitionGenerator {
     private static Map<String, Schema> convertToSchemas(final Module module, final EffectiveModelContext schemaContext,
             final Map<String, Schema> definitions, final DefinitionNames definitionNames,
             final boolean isForSingleModule) throws IOException {
-
-        processIdentities(module, definitions, definitionNames, schemaContext);
         processContainersAndLists(module, definitions, definitionNames, schemaContext);
         processRPCs(module, definitions, definitionNames, schemaContext);
 
@@ -191,7 +189,7 @@ public final class DefinitionGenerator {
                         of processLeafNode).
                      */
                     final Property leafNode = processLeafNode((LeafSchemaNode) node, localName, required, stack,
-                            definitions, definitionNames, module.getNamespace(), module);
+                            module.getNamespace());
                     properties.put(localName, leafNode);
                 }
             }
@@ -318,35 +316,6 @@ public final class DefinitionGenerator {
         return dataNodeProperties.build();
     }
 
-    /**
-     * Processes the 'identity' statement in a yang model and maps it to a 'model' in the Swagger JSON spec.
-     * @param module          The module from which the identity stmt will be processed
-     * @param definitions     The ObjectNode in which the parsed identity will be put as a 'model' obj
-     * @param definitionNames Store for definition names
-     */
-    private static void processIdentities(final Module module, final Map<String, Schema> definitions,
-            final DefinitionNames definitionNames, final EffectiveModelContext context) {
-        final String moduleName = module.getName();
-        final Collection<? extends IdentitySchemaNode> idNodes = module.getIdentities();
-        LOG.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size());
-
-        for (final IdentitySchemaNode idNode : idNodes) {
-            final Schema identityObj = buildIdentityObject(idNode, context);
-            final String idName = idNode.getQName().getLocalName();
-            final String discriminator = definitionNames.pickDiscriminator(idNode, List.of(idName));
-            final String name = idName + discriminator;
-            definitions.put(name, identityObj);
-        }
-    }
-
-    private static void populateEnumWithDerived(final Collection<? extends IdentitySchemaNode> derivedIds,
-            final List<String> enumPayload, final EffectiveModelContext context) {
-        for (final IdentitySchemaNode derivedId : derivedIds) {
-            enumPayload.add(derivedId.getQName().getLocalName());
-            populateEnumWithDerived(context.getDerivedIdentities(derivedId), enumPayload, context);
-        }
-    }
-
     private static Property processDataNodeContainer(final DataNodeContainer dataNode, final String parentName,
             final Map<String, Schema> definitions, final DefinitionNames definitionNames,
             final SchemaInferenceStack stack, final Module module, final boolean isParentConfig) throws IOException {
@@ -469,15 +438,14 @@ public final class DefinitionGenerator {
             processActionNodeContainer(node, parentName, definitions, definitionNames, stack, module);
         } else if (shouldBeAddedAsChild) {
             if (node instanceof LeafSchemaNode leaf) {
-                property = processLeafNode(leaf, name, required, stack, definitions, definitionNames, parentNamespace,
-                    module);
+                property = processLeafNode(leaf, name, required, stack, parentNamespace);
             } else if (node instanceof AnyxmlSchemaNode || node instanceof AnydataSchemaNode) {
                 property = processUnknownDataSchemaNode(node, name, required, parentNamespace);
             } else if (node instanceof LeafListSchemaNode leafList) {
                 if (isSchemaNodeMandatory(node)) {
                     required.add(name);
                 }
-                property = processLeafListNode(leafList, stack, definitions, definitionNames, module);
+                property = processLeafListNode(leafList, stack);
             } else {
                 throw new IllegalArgumentException("Unknown DataSchemaNode type: " + node.getClass());
             }
@@ -487,8 +455,7 @@ public final class DefinitionGenerator {
     }
 
     private static Property processLeafListNode(final LeafListSchemaNode listNode,
-            final SchemaInferenceStack stack, final Map<String, Schema> definitions,
-            final DefinitionNames definitionNames, final Module module) {
+            final SchemaInferenceStack stack) {
         final Property.Builder props = new Property.Builder();
         props.type(ARRAY_TYPE);
 
@@ -496,7 +463,7 @@ public final class DefinitionGenerator {
         final Optional<ElementCountConstraint> optConstraint = listNode.getElementCountConstraint();
         optConstraint.ifPresent(elementCountConstraint -> processElementCount(elementCountConstraint, props));
 
-        processTypeDef(listNode.getType(), listNode, itemsVal, stack, definitions, definitionNames, module);
+        processTypeDef(listNode.getType(), listNode, itemsVal, stack);
 
         props.items(itemsVal.build());
         props.description(listNode.getDescription().orElse(""));
@@ -523,20 +490,13 @@ public final class DefinitionGenerator {
     }
 
     private static Property processLeafNode(final LeafSchemaNode leafNode, final String jsonLeafName,
-            final List<String> required, final SchemaInferenceStack stack, final Map<String, Schema> definitions,
-            final DefinitionNames definitionNames, final XMLNamespace parentNamespace, final Module module) {
+            final List<String> required, final SchemaInferenceStack stack, final XMLNamespace parentNamespace) {
         final Property.Builder property = new Property.Builder();
 
         final String leafDescription = leafNode.getDescription().orElse("");
-        /*
-            Description can't be added, because nothing allowed alongside $ref.
-            allOf is not an option, because ServiceNow can't parse it.
-        */
-        if (!(leafNode.getType() instanceof IdentityrefTypeDefinition)) {
-            property.description(leafDescription);
-        }
+        property.description(leafDescription);
 
-        processTypeDef(leafNode.getType(), leafNode, property, stack, definitions, definitionNames, module);
+        processTypeDef(leafNode.getType(), leafNode, property, stack);
         if (!leafNode.getQName().getNamespace().equals(parentNamespace)) {
             // If the parent is not from the same model, define the child XML namespace.
             property.xml(buildXmlParameter(leafNode));
@@ -566,8 +526,7 @@ public final class DefinitionGenerator {
     }
 
     private static String processTypeDef(final TypeDefinition<?> leafTypeDef, final DataSchemaNode node,
-            final Property.Builder property, final SchemaInferenceStack stack,final Map<String, Schema> definitions,
-            final DefinitionNames definitionNames, final Module module) {
+            final Property.Builder property, final SchemaInferenceStack stack) {
         final String jsonType;
         if (leafTypeDef instanceof BinaryTypeDefinition binaryType) {
             jsonType = processBinaryType(binaryType, property);
@@ -576,18 +535,15 @@ public final class DefinitionGenerator {
         } else if (leafTypeDef instanceof EnumTypeDefinition enumType) {
             jsonType = processEnumType(enumType, property);
         } else if (leafTypeDef instanceof IdentityrefTypeDefinition identityrefType) {
-            jsonType = processIdentityRefType(identityrefType, property, definitions,
-                    definitionNames, stack.getEffectiveModelContext(), module);
+            jsonType = processIdentityRefType(identityrefType, property, stack.getEffectiveModelContext());
         } else if (leafTypeDef instanceof StringTypeDefinition stringType) {
             jsonType = processStringType(stringType, property, node.getQName().getLocalName());
         } else if (leafTypeDef instanceof UnionTypeDefinition unionType) {
-            jsonType = processTypeDef(unionType.getTypes().iterator().next(), node, property, stack, definitions,
-                definitionNames, module);
+            jsonType = processTypeDef(unionType.getTypes().iterator().next(), node, property, stack);
         } else if (leafTypeDef instanceof EmptyTypeDefinition) {
             jsonType = OBJECT_TYPE;
         } else if (leafTypeDef instanceof LeafrefTypeDefinition leafrefType) {
-            return processTypeDef(stack.resolveLeafref(leafrefType), node, property,
-                stack, definitions, definitionNames, module);
+            return processTypeDef(stack.resolveLeafref(leafrefType), node, property, stack);
         } else if (leafTypeDef instanceof BooleanTypeDefinition) {
             jsonType = BOOLEAN_TYPE;
             leafTypeDef.getDefaultValue().ifPresent(v -> property.defaultValue(Boolean.valueOf((String) v)));
@@ -600,32 +556,31 @@ public final class DefinitionGenerator {
         } else {
             jsonType = STRING_TYPE;
         }
-        if (!(leafTypeDef instanceof IdentityrefTypeDefinition)) {
-            if (TYPE_KEY != null && jsonType != null) {
-                property.type(jsonType);
-            }
-            if (leafTypeDef.getDefaultValue().isPresent()) {
-                final Object defaultValue = leafTypeDef.getDefaultValue().orElseThrow();
-                if (defaultValue instanceof String stringDefaultValue) {
-                    if (leafTypeDef instanceof BooleanTypeDefinition) {
-                        property.defaultValue(Boolean.valueOf(stringDefaultValue));
-                    } else if (leafTypeDef instanceof DecimalTypeDefinition
-                            || leafTypeDef instanceof Uint64TypeDefinition) {
-                        property.defaultValue(new BigDecimal(stringDefaultValue));
-                    } else if (leafTypeDef instanceof RangeRestrictedTypeDefinition<?, ?> rangeRestrictedType) {
-                        //uint8,16,32 int8,16,32,64
-                        if (isHexadecimalOrOctal(rangeRestrictedType)) {
-                            property.defaultValue(stringDefaultValue);
-                        } else {
-                            property.defaultValue(Long.valueOf(stringDefaultValue));
-                        }
-                    } else {
+        if (TYPE_KEY != null && jsonType != null) {
+            property.type(jsonType);
+        }
+
+        if (leafTypeDef.getDefaultValue().isPresent()) {
+            final Object defaultValue = leafTypeDef.getDefaultValue().orElseThrow();
+            if (defaultValue instanceof String stringDefaultValue) {
+                if (leafTypeDef instanceof BooleanTypeDefinition) {
+                    property.defaultValue(Boolean.valueOf(stringDefaultValue));
+                } else if (leafTypeDef instanceof DecimalTypeDefinition
+                        || leafTypeDef instanceof Uint64TypeDefinition) {
+                    property.defaultValue(new BigDecimal(stringDefaultValue));
+                } else if (leafTypeDef instanceof RangeRestrictedTypeDefinition<?, ?> rangeRestrictedType) {
+                    //uint8,16,32 int8,16,32,64
+                    if (isHexadecimalOrOctal(rangeRestrictedType)) {
                         property.defaultValue(stringDefaultValue);
+                    } else {
+                        property.defaultValue(Long.valueOf(stringDefaultValue));
                     }
                 } else {
-                    //we should never get here. getDefaultValue always gives us string
-                    property.defaultValue(defaultValue.toString());
+                    property.defaultValue(stringDefaultValue);
                 }
+            } else {
+                //we should never get here. getDefaultValue always gives us string
+                property.defaultValue(defaultValue.toString());
             }
         }
         return jsonType;
@@ -650,55 +605,24 @@ public final class DefinitionGenerator {
     }
 
     private static String processIdentityRefType(final IdentityrefTypeDefinition leafTypeDef,
-            final Property.Builder property, final Map<String, Schema> definitions,
-            final DefinitionNames definitionNames, final EffectiveModelContext schemaContext, final Module module) {
-        final String definitionName;
-        if (isImported(leafTypeDef, module)) {
-            definitionName = addImportedIdentity(leafTypeDef, definitions, definitionNames, schemaContext);
-        } else {
-            final SchemaNode node = leafTypeDef.getIdentities().iterator().next();
-            definitionName = node.getQName().getLocalName() + definitionNames.getDiscriminator(node);
-        }
-        property.ref(COMPONENTS_PREFIX + definitionName);
-        return STRING_TYPE;
-    }
-
-    private static String addImportedIdentity(final IdentityrefTypeDefinition leafTypeDef,
-            final Map<String, Schema> definitions, final DefinitionNames definitionNames,
-            final EffectiveModelContext context) {
-        final IdentitySchemaNode idNode = leafTypeDef.getIdentities().iterator().next();
-        final String identityName = idNode.getQName().getLocalName();
-        if (!definitionNames.isListedNode(idNode)) {
-            final Schema identityObj = buildIdentityObject(idNode, context);
-            final String discriminator = definitionNames.pickDiscriminator(idNode, List.of(identityName));
-            final String name = identityName + discriminator;
-            definitions.put(name, identityObj);
-            return name;
-        } else {
-            return identityName + definitionNames.getDiscriminator(idNode);
-        }
-    }
-
-    private static Schema buildIdentityObject(final IdentitySchemaNode idNode, final EffectiveModelContext context) {
-        final String identityName = idNode.getQName().getLocalName();
-        LOG.debug("Processing Identity: {}", identityName);
-
-        final Collection<? extends IdentitySchemaNode> derivedIds = context.getDerivedIdentities(idNode);
+            final Property.Builder property, final EffectiveModelContext schemaContext) {
+        final IdentitySchemaNode node = leafTypeDef.getIdentities().iterator().next();
+        property.example(node.getQName().getLocalName());
+        final Collection<? extends IdentitySchemaNode> derivedIds = schemaContext.getDerivedIdentities(node);
         final List<String> enumPayload = new ArrayList<>();
-        enumPayload.add(identityName);
-        populateEnumWithDerived(derivedIds, enumPayload, context);
+        enumPayload.add(node.getQName().getLocalName());
+        populateEnumWithDerived(derivedIds, enumPayload, schemaContext);
         final List<String> schemaEnum = new ArrayList<>(enumPayload);
-
-        return new Schema.Builder()
-            .title(identityName)
-            .description(idNode.getDescription().orElse(""))
-            .schemaEnum(schemaEnum)
-            .type(STRING_TYPE)
-            .build();
+        property.enums(schemaEnum);
+        return STRING_TYPE;
     }
 
-    private static boolean isImported(final IdentityrefTypeDefinition leafTypeDef, final Module module) {
-        return !leafTypeDef.getQName().getModule().equals(module.getQNameModule());
+    private static void populateEnumWithDerived(final Collection<? extends IdentitySchemaNode> derivedIds,
+            final List<String> enumPayload, final EffectiveModelContext context) {
+        for (final IdentitySchemaNode derivedId : derivedIds) {
+            enumPayload.add(derivedId.getQName().getLocalName());
+            populateEnumWithDerived(context.getDerivedIdentities(derivedId), enumPayload, context);
+        }
     }
 
     private static String processBitsType(final BitsTypeDefinition bitsType, final Property.Builder property) {
index ae07af5a352c25fa766603762b86e3060c317b31..2ed09d622d85fef71354f2fd192e94b3d82ec6e2 100644 (file)
@@ -9,11 +9,13 @@ package org.opendaylight.restconf.openapi.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.util.Set;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
@@ -178,4 +180,32 @@ public final class DefinitionGeneratorTest {
         assertNotNull(namespace);
         assertEquals("urn:ietf:params:xml:ns:yang:test:action:types", namespace);
     }
+
+    /**
+     *  This test is designed to verify if yang Identity is used correctly as string value
+     *  and no extra schemas are generated.
+     */
+    @Test
+    public void testIdentity() throws IOException {
+        final var module = context.findModule("toaster", Revision.of("2009-11-20")).orElseThrow();
+        final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true);
+        assertNotNull(schemas);
+
+        // correct number of schemas generated
+        assertEquals(3, schemas.size());
+        final var makeToast = schemas.get("toaster_make-toast_input").properties().get("toasterToastType");
+
+        assertEquals("wheat-bread", makeToast.defaultValue().toString());
+        assertEquals("toast-type", makeToast.example().toString());
+        assertEquals("string", makeToast.type());
+        assertEquals("""
+                This variable informs the toaster of the type of
+                      material that is being toasted. The toaster
+                      uses this information, combined with
+                      toasterDoneness, to compute for how
+                      long the material must be toasted to achieve
+                      the required doneness.""", makeToast.description());
+        assertTrue(makeToast.enums().containsAll(Set.of("toast-type","white-bread", "wheat-bread", "frozen-waffle",
+            "hash-brown", "frozen-bagel", "wonder-bread")));
+    }
 }
index 175c24f9852c3684fcf3ed665baac73588bdbac2..51702c79fb9b13c84f35b5706b804c15620640b7 100644 (file)
@@ -373,7 +373,7 @@ public final class OpenApiGeneratorRFC8040Test {
 
         // Test `components/schemas` objects
         final var definitions = doc.components().schemas();
-        assertEquals(18, definitions.size());
+        assertEquals(11, definitions.size());
     }
 
     /**
index 297a236be36039cae9239c76b19715f2003e7070..380ef8e56e49b4a84748268f14aa4fbc1509147a 100644 (file)
   },
   "components": {
     "schemas": {
-      "hash-brown": {
-        "enum": [
-          "hash-brown"
-        ],
-        "description": "Hash browned potatos.",
-        "title": "hash-brown",
-        "type": "string"
-      },
-      "toaster_make-toast_input": {
+      "toaster_restock-toaster_input": {
         "properties": {
-          "toasterDoneness": {
-            "default": 5,
-            "description": "This variable controls how well-done is the\nensuing toast. It should be on a scale of 1 to 10.\nToast made at 10 generally is considered unfit\nfor human consumption; toast made at 1 is warmed\nlightly.",
+          "amountOfBreadToStock": {
+            "description": "Indicates the amount of bread to re-stock",
             "type": "integer",
-            "example": 1,
+            "example": 0,
             "format": "int64"
-          },
-          "toasterToastType": {
-            "$ref": "#/components/schemas/toast-type"
           }
         },
         "xml": {
           "name": "input",
           "namespace": "http://netconfcentral.org/ns/toaster"
         },
-        "title": "toaster_make-toast_input",
+        "title": "toaster_restock-toaster_input",
         "type": "object"
       },
-      "toast-type": {
-        "enum": [
-          "toast-type",
-          "wheat-bread",
-          "frozen-bagel",
-          "white-bread",
-          "wonder-bread",
-          "hash-brown",
-          "frozen-waffle"
-        ],
-        "description": "Base for all bread types supported by the toaster.\nNew bread types not listed here nay be added in the\nfuture.",
-        "title": "toast-type",
-        "type": "string"
-      },
-      "frozen-bagel": {
-        "enum": [
-          "frozen-bagel"
-        ],
-        "description": "Frozen bagel.",
-        "title": "frozen-bagel",
-        "type": "string"
-      },
-      "toaster_restock-toaster_input": {
+      "toaster_make-toast_input": {
         "properties": {
-          "amountOfBreadToStock": {
-            "description": "Indicates the amount of bread to re-stock",
+          "toasterDoneness": {
+            "default": 5,
+            "description": "This variable controls how well-done is the\nensuing toast. It should be on a scale of 1 to 10.\nToast made at 10 generally is considered unfit\nfor human consumption; toast made at 1 is warmed\nlightly.",
             "type": "integer",
-            "example": 0,
+            "example": 1,
             "format": "int64"
+          },
+          "toasterToastType": {
+            "default": "wheat-bread",
+            "description": "This variable informs the toaster of the type of\nmaterial that is being toasted. The toaster\nuses this information, combined with\ntoasterDoneness, to compute for how\nlong the material must be toasted to achieve\nthe required doneness.",
+            "type": "string",
+            "example": "toast-type",
+            "enum": [
+              "toast-type",
+              "frozen-bagel",
+              "hash-brown",
+              "wonder-bread",
+              "frozen-waffle",
+              "white-bread",
+              "wheat-bread"
+            ]
           }
         },
         "xml": {
           "name": "input",
           "namespace": "http://netconfcentral.org/ns/toaster"
         },
-        "title": "toaster_restock-toaster_input",
+        "title": "toaster_make-toast_input",
         "type": "object"
       },
-      "frozen-waffle": {
-        "enum": [
-          "frozen-waffle"
-        ],
-        "description": "Frozen waffle.",
-        "title": "frozen-waffle",
-        "type": "string"
-      },
-      "white-bread": {
-        "enum": [
-          "white-bread"
-        ],
-        "description": "White bread.",
-        "title": "white-bread",
-        "type": "string"
-      },
-      "wheat-bread": {
-        "enum": [
-          "wheat-bread"
-        ],
-        "description": "Wheat bread.",
-        "title": "wheat-bread",
-        "type": "string"
-      },
-      "wonder-bread": {
-        "enum": [
-          "wonder-bread"
-        ],
-        "description": "Wonder bread.",
-        "title": "wonder-bread",
-        "type": "string"
-      },
       "toaster_toaster": {
         "properties": {
           "darknessFactor": {
index f77a1c8455692014b3e66d23ae17f1d0f67faa42..c6fd874cbd7045f57c2c7260d44029e666f62b50 100644 (file)
   },
   "components": {
     "schemas": {
-      "hash-brown": {
-        "enum": [
-          "hash-brown"
-        ],
-        "description": "Hash browned potatos.",
-        "title": "hash-brown",
-        "type": "string"
-      },
       "toaster_make-toast_input": {
         "properties": {
           "toasterDoneness": {
             "format": "int64"
           },
           "toasterToastType": {
-            "$ref": "#/components/schemas/toast-type"
+            "default": "wheat-bread",
+            "description": "This variable informs the toaster of the type of\nmaterial that is being toasted. The toaster\nuses this information, combined with\ntoasterDoneness, to compute for how\nlong the material must be toasted to achieve\nthe required doneness.",
+            "type": "string",
+            "example": "toast-type",
+            "enum": [
+              "toast-type",
+              "frozen-bagel",
+              "hash-brown",
+              "wonder-bread",
+              "frozen-waffle",
+              "white-bread",
+              "wheat-bread"
+            ]
           }
         },
         "xml": {
         "title": "toaster_make-toast_input",
         "type": "object"
       },
-      "toast-type": {
-        "enum": [
-          "toast-type",
-          "white-bread",
-          "wonder-bread",
-          "hash-brown",
-          "frozen-waffle",
-          "wheat-bread",
-          "frozen-bagel"
-        ],
-        "description": "Base for all bread types supported by the toaster.\nNew bread types not listed here nay be added in the\nfuture.",
-        "title": "toast-type",
-        "type": "string"
-      },
       "toaster_module": {
         "properties": {
           "toaster": {
         "title": "toaster_module",
         "type": "object"
       },
-      "frozen-bagel": {
-        "enum": [
-          "frozen-bagel"
-        ],
-        "description": "Frozen bagel.",
-        "title": "frozen-bagel",
-        "type": "string"
-      },
       "toaster_restock-toaster_input": {
         "properties": {
           "amountOfBreadToStock": {
         "title": "toaster_restock-toaster_input",
         "type": "object"
       },
-      "frozen-waffle": {
-        "enum": [
-          "frozen-waffle"
-        ],
-        "description": "Frozen waffle.",
-        "title": "frozen-waffle",
-        "type": "string"
-      },
-      "white-bread": {
-        "enum": [
-          "white-bread"
-        ],
-        "description": "White bread.",
-        "title": "white-bread",
-        "type": "string"
-      },
-      "wheat-bread": {
-        "enum": [
-          "wheat-bread"
-        ],
-        "description": "Wheat bread.",
-        "title": "wheat-bread",
-        "type": "string"
-      },
-      "wonder-bread": {
-        "enum": [
-          "wonder-bread"
-        ],
-        "description": "Wonder bread.",
-        "title": "wonder-bread",
-        "type": "string"
-      },
       "toaster_toaster": {
         "properties": {
           "darknessFactor": {
index c4194c09eff9e3ed7195c0cf04b7ce56039c100c..b7b3e978020e3aefefe40b040016db96c616cb64 100644 (file)
   },
   "components": {
     "schemas": {
-      "hash-brown": {
-        "enum": [
-          "hash-brown"
-        ],
-        "description": "Hash browned potatos.",
-        "title": "hash-brown",
-        "type": "string"
-      },
-      "toaster_make-toast_input": {
+      "toaster_restock-toaster_input": {
         "properties": {
-          "toasterDoneness": {
-            "default": 5,
-            "description": "This variable controls how well-done is the\nensuing toast. It should be on a scale of 1 to 10.\nToast made at 10 generally is considered unfit\nfor human consumption; toast made at 1 is warmed\nlightly.",
+          "amountOfBreadToStock": {
+            "description": "Indicates the amount of bread to re-stock",
             "type": "integer",
-            "example": 1,
+            "example": 0,
             "format": "int64"
-          },
-          "toasterToastType": {
-            "$ref": "#/components/schemas/toast-type"
           }
         },
         "xml": {
           "name": "input",
           "namespace": "http://netconfcentral.org/ns/toaster"
         },
-        "title": "toaster_make-toast_input",
+        "title": "toaster_restock-toaster_input",
         "type": "object"
       },
-      "toast-type": {
-        "enum": [
-          "toast-type",
-          "hash-brown",
-          "white-bread",
-          "frozen-waffle",
-          "wheat-bread",
-          "wonder-bread",
-          "frozen-bagel"
-        ],
-        "description": "Base for all bread types supported by the toaster.\nNew bread types not listed here nay be added in the\nfuture.",
-        "title": "toast-type",
-        "type": "string"
-      },
-      "frozen-bagel": {
-        "enum": [
-          "frozen-bagel"
-        ],
-        "description": "Frozen bagel.",
-        "title": "frozen-bagel",
-        "type": "string"
-      },
-      "toaster_restock-toaster_input": {
+      "toaster_make-toast_input": {
         "properties": {
-          "amountOfBreadToStock": {
-            "description": "Indicates the amount of bread to re-stock",
+          "toasterToastType": {
+            "default": "wheat-bread",
+            "description": "This variable informs the toaster of the type of\nmaterial that is being toasted. The toaster\nuses this information, combined with\ntoasterDoneness, to compute for how\nlong the material must be toasted to achieve\nthe required doneness.",
+            "type": "string",
+            "example": "toast-type",
+            "enum": [
+              "toast-type",
+              "frozen-bagel",
+              "hash-brown",
+              "wonder-bread",
+              "frozen-waffle",
+              "white-bread",
+              "wheat-bread"
+            ]
+          },
+          "toasterDoneness": {
+            "default": 5,
+            "description": "This variable controls how well-done is the\nensuing toast. It should be on a scale of 1 to 10.\nToast made at 10 generally is considered unfit\nfor human consumption; toast made at 1 is warmed\nlightly.",
             "type": "integer",
-            "example": 0,
+            "example": 1,
             "format": "int64"
           }
         },
           "name": "input",
           "namespace": "http://netconfcentral.org/ns/toaster"
         },
-        "title": "toaster_restock-toaster_input",
+        "title": "toaster_make-toast_input",
         "type": "object"
       },
-      "frozen-waffle": {
-        "enum": [
-          "frozen-waffle"
-        ],
-        "description": "Frozen waffle.",
-        "title": "frozen-waffle",
-        "type": "string"
-      },
-      "white-bread": {
-        "enum": [
-          "white-bread"
-        ],
-        "description": "White bread.",
-        "title": "white-bread",
-        "type": "string"
-      },
-      "wheat-bread": {
-        "enum": [
-          "wheat-bread"
-        ],
-        "description": "Wheat bread.",
-        "title": "wheat-bread",
-        "type": "string"
-      },
-      "wonder-bread": {
-        "enum": [
-          "wonder-bread"
-        ],
-        "description": "Wonder bread.",
-        "title": "wonder-bread",
-        "type": "string"
-      },
       "toaster_toaster": {
         "properties": {
           "darknessFactor": {
index d40e6a33645138c6603ad9eef133285185e7810a..136ac9cc151dc67f3bb0bd3327a495ede5a5b41f 100644 (file)
   },
   "components": {
     "schemas": {
-      "hash-brown": {
-        "enum": [
-          "hash-brown"
-        ],
-        "description": "Hash browned potatos.",
-        "title": "hash-brown",
-        "type": "string"
-      },
       "toaster_make-toast_input": {
         "properties": {
+          "toasterToastType": {
+            "default": "wheat-bread",
+            "description": "This variable informs the toaster of the type of\nmaterial that is being toasted. The toaster\nuses this information, combined with\ntoasterDoneness, to compute for how\nlong the material must be toasted to achieve\nthe required doneness.",
+            "type": "string",
+            "example": "toast-type",
+            "enum": [
+              "toast-type",
+              "frozen-bagel",
+              "hash-brown",
+              "wonder-bread",
+              "frozen-waffle",
+              "white-bread",
+              "wheat-bread"
+            ]
+          },
           "toasterDoneness": {
             "default": 5,
             "description": "This variable controls how well-done is the\nensuing toast. It should be on a scale of 1 to 10.\nToast made at 10 generally is considered unfit\nfor human consumption; toast made at 1 is warmed\nlightly.",
             "type": "integer",
             "example": 1,
             "format": "int64"
-          },
-          "toasterToastType": {
-            "$ref": "#/components/schemas/toast-type"
           }
         },
         "xml": {
         "title": "toaster_make-toast_input",
         "type": "object"
       },
-      "toast-type": {
-        "enum": [
-          "toast-type",
-          "wonder-bread",
-          "frozen-waffle",
-          "frozen-bagel",
-          "hash-brown",
-          "white-bread",
-          "wheat-bread"
-        ],
-        "description": "Base for all bread types supported by the toaster.\nNew bread types not listed here nay be added in the\nfuture.",
-        "title": "toast-type",
-        "type": "string"
-      },
       "toaster_module": {
         "properties": {
           "toaster": {
         "title": "toaster_module",
         "type": "object"
       },
-      "frozen-bagel": {
-        "enum": [
-          "frozen-bagel"
-        ],
-        "description": "Frozen bagel.",
-        "title": "frozen-bagel",
-        "type": "string"
-      },
       "toaster_restock-toaster_input": {
         "properties": {
           "amountOfBreadToStock": {
         "title": "toaster_restock-toaster_input",
         "type": "object"
       },
-      "frozen-waffle": {
-        "enum": [
-          "frozen-waffle"
-        ],
-        "description": "Frozen waffle.",
-        "title": "frozen-waffle",
-        "type": "string"
-      },
-      "white-bread": {
-        "enum": [
-          "white-bread"
-        ],
-        "description": "White bread.",
-        "title": "white-bread",
-        "type": "string"
-      },
-      "wheat-bread": {
-        "enum": [
-          "wheat-bread"
-        ],
-        "description": "Wheat bread.",
-        "title": "wheat-bread",
-        "type": "string"
-      },
-      "wonder-bread": {
-        "enum": [
-          "wonder-bread"
-        ],
-        "description": "Wonder bread.",
-        "title": "wonder-bread",
-        "type": "string"
-      },
       "toaster_toaster": {
         "properties": {
           "darknessFactor": {