BUG-432: migrate users of Registration as appropriate
[controller.git] / opendaylight / md-sal / sal-rest-docgen / src / main / java / org / opendaylight / controller / sal / rest / doc / impl / ModelGenerator.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.rest.doc.impl;
9
10 import java.io.IOException;
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Set;
17 import org.apache.commons.lang3.BooleanUtils;
18 import org.json.JSONArray;
19 import org.json.JSONException;
20 import org.json.JSONObject;
21 import org.opendaylight.controller.sal.rest.doc.model.builder.OperationBuilder;
22 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
24 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
25 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
26 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
27 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
28 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
29 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
30 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
31 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
32 import org.opendaylight.yangtools.yang.model.api.Module;
33 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
34 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
35 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
36 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
37 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
38 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
39 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
40 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
41 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
42 import org.opendaylight.yangtools.yang.model.util.BooleanType;
43 import org.opendaylight.yangtools.yang.model.util.Decimal64;
44 import org.opendaylight.yangtools.yang.model.util.EnumerationType;
45 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
46 import org.opendaylight.yangtools.yang.model.util.Int16;
47 import org.opendaylight.yangtools.yang.model.util.Int32;
48 import org.opendaylight.yangtools.yang.model.util.Int64;
49 import org.opendaylight.yangtools.yang.model.util.Int8;
50 import org.opendaylight.yangtools.yang.model.util.StringType;
51 import org.opendaylight.yangtools.yang.model.util.Uint16;
52 import org.opendaylight.yangtools.yang.model.util.Uint32;
53 import org.opendaylight.yangtools.yang.model.util.Uint64;
54 import org.opendaylight.yangtools.yang.model.util.Uint8;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
57
58 /**
59  * Generates JSON Schema for data defined in Yang
60  */
61 public class ModelGenerator {
62
63     private static Logger _logger = LoggerFactory.getLogger(ModelGenerator.class);
64
65     private static final String BASE_64 = "base64";
66     private static final String BINARY_ENCODING_KEY = "binaryEncoding";
67     private static final String MEDIA_KEY = "media";
68     private static final String ONE_OF_KEY = "oneOf";
69     private static final String UNIQUE_ITEMS_KEY = "uniqueItems";
70     private static final String MAX_ITEMS = "maxItems";
71     private static final String MIN_ITEMS = "minItems";
72     private static final String SCHEMA_URL = "http://json-schema.org/draft-04/schema";
73     private static final String SCHEMA_KEY = "$schema";
74     private static final String MAX_LENGTH_KEY = "maxLength";
75     private static final String MIN_LENGTH_KEY = "minLength";
76     private static final String REQUIRED_KEY = "required";
77     private static final String REF_KEY = "$ref";
78     private static final String ITEMS_KEY = "items";
79     private static final String TYPE_KEY = "type";
80     private static final String PROPERTIES_KEY = "properties";
81     private static final String DESCRIPTION_KEY = "description";
82     private static final String OBJECT_TYPE = "object";
83     private static final String ARRAY_TYPE = "array";
84     private static final String ENUM = "enum";
85     private static final String INTEGER = "integer";
86     private static final String NUMBER = "number";
87     private static final String BOOLEAN = "boolean";
88     private static final String STRING = "string";
89   private static final String ID_KEY = "id";
90   private static final String SUB_TYPES_KEY = "subTypes";
91
92     private static final Map<Class<? extends TypeDefinition<?>>, String> YANG_TYPE_TO_JSON_TYPE_MAPPING;
93
94     static {
95         Map<Class<? extends TypeDefinition<?>>, String> tempMap1 = new HashMap<Class<? extends TypeDefinition<?>>, String>(
96                 10);
97         tempMap1.put(StringType.class, STRING);
98         tempMap1.put(BooleanType.class, BOOLEAN);
99         tempMap1.put(Int8.class, INTEGER);
100         tempMap1.put(Int16.class, INTEGER);
101         tempMap1.put(Int32.class, INTEGER);
102         tempMap1.put(Int64.class, INTEGER);
103         tempMap1.put(Uint16.class, INTEGER);
104         tempMap1.put(Uint32.class, INTEGER);
105         tempMap1.put(Uint64.class, INTEGER);
106         tempMap1.put(Uint8.class, INTEGER);
107         tempMap1.put(Decimal64.class, NUMBER);
108         tempMap1.put(EnumerationType.class, ENUM);
109         // TODO: Binary type
110
111         YANG_TYPE_TO_JSON_TYPE_MAPPING = Collections.unmodifiableMap(tempMap1);
112     }
113
114     public ModelGenerator() {
115     }
116
117     public JSONObject convertToJsonSchema(Module module) throws IOException, JSONException {
118         JSONObject models = new JSONObject();
119         processContainers(module, models);
120         processRPCs(module, models);
121     processIdentities(module, models);
122         return models;
123     }
124
125     private void processContainers(Module module, JSONObject models) throws IOException,
126             JSONException {
127
128         String moduleName = module.getName();
129         Set<DataSchemaNode> childNodes = module.getChildNodes();
130
131         for (DataSchemaNode childNode : childNodes) {
132             JSONObject configModuleJSON = null;
133             JSONObject operationalModuleJSON = null;
134
135             String childNodeName = childNode.getQName().getLocalName();
136             /*
137              * For every container in the module
138              */
139             if (childNode instanceof ContainerSchemaNode) {
140                 configModuleJSON = processContainer((ContainerSchemaNode) childNode, moduleName,
141                         true, models, true);
142                 operationalModuleJSON = processContainer((ContainerSchemaNode) childNode,
143                         moduleName, true, models, false);
144             }
145
146             if (configModuleJSON != null) {
147                 _logger.debug("Adding model for [{}]", OperationBuilder.CONFIG + childNodeName);
148                 configModuleJSON.put("id", OperationBuilder.CONFIG + childNodeName);
149                 models.put(OperationBuilder.CONFIG + childNodeName, configModuleJSON);
150             }
151             if (operationalModuleJSON != null) {
152                 _logger.debug("Adding model for [{}]", OperationBuilder.OPERATIONAL + childNodeName);
153                 operationalModuleJSON.put("id", OperationBuilder.OPERATIONAL + childNodeName);
154                 models.put(OperationBuilder.OPERATIONAL + childNodeName, operationalModuleJSON);
155             }
156         }
157
158     }
159
160     /**
161      * Process the RPCs for a Module Spits out a file each of the name
162      * <rpcName>-input.json and <rpcName>-output.json for each RPC that contains
163      * input & output elements
164      *
165      * @param module
166      * @throws JSONException
167      * @throws IOException
168      */
169     private void processRPCs(Module module, JSONObject models) throws JSONException, IOException {
170
171         Set<RpcDefinition> rpcs = module.getRpcs();
172         String moduleName = module.getName();
173         for (RpcDefinition rpc : rpcs) {
174
175             ContainerSchemaNode input = rpc.getInput();
176             if (input != null) {
177                 JSONObject inputJSON = processContainer(input, moduleName, true, models);
178                 String filename = "(" + rpc.getQName().getLocalName() + ")input";
179                 inputJSON.put("id", filename);
180                 // writeToFile(filename, inputJSON.toString(2), moduleName);
181                 models.put(filename, inputJSON);
182             }
183
184             ContainerSchemaNode output = rpc.getOutput();
185             if (output != null) {
186                 JSONObject outputJSON = processContainer(output, moduleName, true, models);
187                 String filename = "(" + rpc.getQName().getLocalName() + ")output";
188                 outputJSON.put("id", filename);
189                 models.put(filename, outputJSON);
190             }
191         }
192     }
193
194   /**
195    * Processes the 'identity' statement in a yang model
196    * and maps it to a 'model' in the Swagger JSON spec.
197    *
198    * @param module The module from which the identity stmt will be processed
199    * @param models The JSONObject in which the parsed identity will be put as a 'model' obj
200    * @throws JSONException
201    */
202   private void processIdentities(Module module, JSONObject models) throws JSONException {
203
204     String moduleName = module.getName();
205     Set<IdentitySchemaNode> idNodes =  module.getIdentities();
206     _logger.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size());
207
208     for(IdentitySchemaNode idNode : idNodes){
209       JSONObject identityObj=new JSONObject();
210       String identityName = idNode.getQName().getLocalName();
211       _logger.debug("Processing Identity: {}", identityName);
212
213       identityObj.put(ID_KEY, identityName);
214       identityObj.put(DESCRIPTION_KEY, idNode.getDescription());
215
216       JSONObject props = new JSONObject();
217       IdentitySchemaNode baseId = idNode.getBaseIdentity();
218
219
220       if(baseId==null) {
221         /**
222          * This is a base identity. So lets see if
223          * it has sub types. If it does, then add them to the model definition.
224          */
225         Set<IdentitySchemaNode> derivedIds = idNode.getDerivedIdentities();
226
227         if(derivedIds != null) {
228           JSONArray subTypes = new JSONArray();
229           for(IdentitySchemaNode derivedId : derivedIds){
230             subTypes.put(derivedId.getQName().getLocalName());
231           }
232           identityObj.put(SUB_TYPES_KEY, subTypes);
233         }
234       } else {
235         /**
236          * This is a derived entity. Add it's base type & move on.
237          */
238         props.put(TYPE_KEY, baseId.getQName().getLocalName());
239       }
240
241       //Add the properties. For a base type, this will be an empty object as required by the Swagger spec.
242       identityObj.put(PROPERTIES_KEY, props);
243       models.put(identityName, identityObj);
244     }
245   }
246     /**
247      * Processes the container node and populates the moduleJSON
248      *
249      * @param container
250      * @param moduleName
251      * @param isConfig
252      * @throws JSONException
253      * @throws IOException
254      */
255     private JSONObject processContainer(ContainerSchemaNode container, String moduleName,
256             boolean addSchemaStmt, JSONObject models) throws JSONException, IOException {
257         return processContainer(container, moduleName, addSchemaStmt, models, (Boolean) null);
258     }
259
260     private JSONObject processContainer(ContainerSchemaNode container, String moduleName,
261             boolean addSchemaStmt, JSONObject models, Boolean isConfig) throws JSONException,
262             IOException {
263         JSONObject moduleJSON = getSchemaTemplate();
264         if (addSchemaStmt) {
265             moduleJSON = getSchemaTemplate();
266         } else {
267             moduleJSON = new JSONObject();
268         }
269         moduleJSON.put(TYPE_KEY, OBJECT_TYPE);
270
271         String containerDescription = container.getDescription();
272         moduleJSON.put(DESCRIPTION_KEY, containerDescription);
273
274         Set<DataSchemaNode> containerChildren = container.getChildNodes();
275         JSONObject properties = processChildren(containerChildren, moduleName, models, isConfig);
276         moduleJSON.put(PROPERTIES_KEY, properties);
277         return moduleJSON;
278     }
279
280     private JSONObject processChildren(Set<DataSchemaNode> nodes, String moduleName,
281             JSONObject models) throws JSONException, IOException {
282         return processChildren(nodes, moduleName, models, null);
283     }
284
285     /**
286      * Processes the nodes
287      *
288      * @param nodes
289      * @param moduleName
290      * @param isConfig
291      * @return
292      * @throws JSONException
293      * @throws IOException
294      */
295     private JSONObject processChildren(Set<DataSchemaNode> nodes, String moduleName,
296             JSONObject models, Boolean isConfig) throws JSONException, IOException {
297
298         JSONObject properties = new JSONObject();
299
300         for (DataSchemaNode node : nodes) {
301             if (isConfig == null || node.isConfiguration() == isConfig) {
302
303                 String name = node.getQName().getLocalName();
304                 JSONObject property = null;
305                 if (node instanceof LeafSchemaNode) {
306                     property = processLeafNode((LeafSchemaNode) node);
307                 } else if (node instanceof ListSchemaNode) {
308                     property = processListSchemaNode((ListSchemaNode) node, moduleName, models, isConfig);
309
310                 } else if (node instanceof LeafListSchemaNode) {
311                     property = processLeafListNode((LeafListSchemaNode) node);
312
313                 } else if (node instanceof ChoiceNode) {
314                     property = processChoiceNode((ChoiceNode) node, moduleName, models);
315
316                 } else if (node instanceof AnyXmlSchemaNode) {
317                     property = processAnyXMLNode((AnyXmlSchemaNode) node);
318
319                 } else if (node instanceof ContainerSchemaNode) {
320                     property = processContainer((ContainerSchemaNode) node, moduleName, false,
321                             models, isConfig);
322
323                 } else {
324                     throw new IllegalArgumentException("Unknown DataSchemaNode type: "
325                             + node.getClass());
326                 }
327
328                 property.putOpt(DESCRIPTION_KEY, node.getDescription());
329                 properties.put(name, property);
330             }
331         }
332         return properties;
333     }
334
335     /**
336      *
337      * @param listNode
338      * @throws JSONException
339      */
340     private JSONObject processLeafListNode(LeafListSchemaNode listNode) throws JSONException {
341         JSONObject props = new JSONObject();
342         props.put(TYPE_KEY, ARRAY_TYPE);
343
344         JSONObject itemsVal = new JSONObject();
345         processTypeDef(listNode.getType(), itemsVal);
346         props.put(ITEMS_KEY, itemsVal);
347
348         ConstraintDefinition constraints = listNode.getConstraints();
349         processConstraints(constraints, props);
350
351         return props;
352     }
353
354     /**
355      *
356      * @param choiceNode
357      * @param moduleName
358      * @throws JSONException
359      * @throws IOException
360      */
361     private JSONObject processChoiceNode(ChoiceNode choiceNode, String moduleName, JSONObject models)
362             throws JSONException, IOException {
363
364         Set<ChoiceCaseNode> cases = choiceNode.getCases();
365
366         JSONArray choiceProps = new JSONArray();
367         for (ChoiceCaseNode choiceCase : cases) {
368             String choiceName = choiceCase.getQName().getLocalName();
369             JSONObject choiceProp = processChildren(choiceCase.getChildNodes(), moduleName, models);
370             JSONObject choiceObj = new JSONObject();
371             choiceObj.put(choiceName, choiceProp);
372             choiceObj.put(TYPE_KEY, OBJECT_TYPE);
373             choiceProps.put(choiceObj);
374         }
375
376         JSONObject oneOfProps = new JSONObject();
377         oneOfProps.put(ONE_OF_KEY, choiceProps);
378         oneOfProps.put(TYPE_KEY, OBJECT_TYPE);
379
380         return oneOfProps;
381     }
382
383     /**
384      *
385      * @param constraints
386      * @param props
387      * @throws JSONException
388      */
389     private void processConstraints(ConstraintDefinition constraints, JSONObject props)
390             throws JSONException {
391         boolean isMandatory = constraints.isMandatory();
392         props.put(REQUIRED_KEY, isMandatory);
393
394         Integer minElements = constraints.getMinElements();
395         Integer maxElements = constraints.getMaxElements();
396         if (minElements != null) {
397             props.put(MIN_ITEMS, minElements);
398         }
399         if (maxElements != null) {
400             props.put(MAX_ITEMS, maxElements);
401         }
402     }
403
404     /**
405      * Parses a ListSchema node.
406      *
407      * Due to a limitation of the RAML--->JAX-RS tool, sub-properties must be in
408      * a separate JSON schema file. Hence, we have to write some properties to a
409      * new file, while continuing to process the rest.
410      *
411      * @param listNode
412      * @param moduleName
413      * @param isConfig
414      * @return
415      * @throws JSONException
416      * @throws IOException
417      */
418     private JSONObject processListSchemaNode(ListSchemaNode listNode, String moduleName,
419             JSONObject models, Boolean isConfig) throws JSONException, IOException {
420
421         Set<DataSchemaNode> listChildren = listNode.getChildNodes();
422         String fileName = (BooleanUtils.isNotFalse(isConfig)?OperationBuilder.CONFIG:OperationBuilder.OPERATIONAL) +
423                                                                 listNode.getQName().getLocalName();
424
425         JSONObject childSchemaProperties = processChildren(listChildren, moduleName, models);
426         JSONObject childSchema = getSchemaTemplate();
427         childSchema.put(TYPE_KEY, OBJECT_TYPE);
428         childSchema.put(PROPERTIES_KEY, childSchemaProperties);
429
430         /*
431          * Due to a limitation of the RAML--->JAX-RS tool, sub-properties must
432          * be in a separate JSON schema file. Hence, we have to write some
433          * properties to a new file, while continuing to process the rest.
434          */
435         // writeToFile(fileName, childSchema.toString(2), moduleName);
436         childSchema.put("id", fileName);
437         models.put(fileName, childSchema);
438
439         JSONObject listNodeProperties = new JSONObject();
440         listNodeProperties.put(TYPE_KEY, ARRAY_TYPE);
441
442         JSONObject items = new JSONObject();
443         items.put(REF_KEY, fileName);
444         listNodeProperties.put(ITEMS_KEY, items);
445
446         return listNodeProperties;
447
448     }
449
450     /**
451      *
452      * @param leafNode
453      * @return
454      * @throws JSONException
455      */
456     private JSONObject processLeafNode(LeafSchemaNode leafNode) throws JSONException {
457         JSONObject property = new JSONObject();
458
459         String leafDescription = leafNode.getDescription();
460         property.put(DESCRIPTION_KEY, leafDescription);
461
462         processConstraints(leafNode.getConstraints(), property);
463         processTypeDef(leafNode.getType(), property);
464
465         return property;
466     }
467
468     /**
469      *
470      * @param leafNode
471      * @return
472      * @throws JSONException
473      */
474     private JSONObject processAnyXMLNode(AnyXmlSchemaNode leafNode) throws JSONException {
475         JSONObject property = new JSONObject();
476
477         String leafDescription = leafNode.getDescription();
478         property.put(DESCRIPTION_KEY, leafDescription);
479
480         processConstraints(leafNode.getConstraints(), property);
481
482         return property;
483     }
484
485     /**
486      * @param property
487      * @throws JSONException
488      */
489     private void processTypeDef(TypeDefinition<?> leafTypeDef, JSONObject property)
490             throws JSONException {
491
492         if (leafTypeDef instanceof ExtendedType) {
493             processExtendedType(leafTypeDef, property);
494         } else if (leafTypeDef instanceof EnumerationType) {
495             processEnumType((EnumerationType) leafTypeDef, property);
496
497         } else if (leafTypeDef instanceof BitsTypeDefinition) {
498             processBitsType((BitsTypeDefinition) leafTypeDef, property);
499
500         } else if (leafTypeDef instanceof UnionTypeDefinition) {
501             processUnionType((UnionTypeDefinition) leafTypeDef, property);
502
503         } else if (leafTypeDef instanceof IdentityrefTypeDefinition) {
504       property.putOpt(TYPE_KEY, ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName());
505         } else if (leafTypeDef instanceof BinaryTypeDefinition) {
506             processBinaryType((BinaryTypeDefinition) leafTypeDef, property);
507         } else {
508             // System.out.println("In else: " + leafTypeDef.getClass());
509             String jsonType = YANG_TYPE_TO_JSON_TYPE_MAPPING.get(leafTypeDef.getClass());
510             if (jsonType == null) {
511                 jsonType = "object";
512             }
513             property.putOpt(TYPE_KEY, jsonType);
514         }
515     }
516
517     /**
518      *
519      * @param leafTypeDef
520      * @param property
521      * @throws JSONException
522      */
523     private void processExtendedType(TypeDefinition<?> leafTypeDef, JSONObject property)
524             throws JSONException {
525         Object leafBaseType = leafTypeDef.getBaseType();
526         if (leafBaseType instanceof ExtendedType) {
527             // recursively process an extended type until we hit a base type
528             processExtendedType((TypeDefinition<?>) leafBaseType, property);
529         } else {
530             List<LengthConstraint> lengthConstraints = ((ExtendedType) leafTypeDef)
531                     .getLengthConstraints();
532             for (LengthConstraint lengthConstraint : lengthConstraints) {
533                 Number min = lengthConstraint.getMin();
534                 Number max = lengthConstraint.getMax();
535                 property.putOpt(MIN_LENGTH_KEY, min);
536                 property.putOpt(MAX_LENGTH_KEY, max);
537             }
538             String jsonType = YANG_TYPE_TO_JSON_TYPE_MAPPING.get(leafBaseType.getClass());
539             property.putOpt(TYPE_KEY, jsonType);
540         }
541
542     }
543
544     /*
545    *
546    */
547     private void processBinaryType(BinaryTypeDefinition binaryType, JSONObject property)
548             throws JSONException {
549         property.put(TYPE_KEY, STRING);
550         JSONObject media = new JSONObject();
551         media.put(BINARY_ENCODING_KEY, BASE_64);
552         property.put(MEDIA_KEY, media);
553     }
554
555     /**
556      *
557      * @param enumLeafType
558      * @param property
559      * @throws JSONException
560      */
561     private void processEnumType(EnumerationType enumLeafType, JSONObject property)
562             throws JSONException {
563         List<EnumPair> enumPairs = enumLeafType.getValues();
564         List<String> enumNames = new ArrayList<String>();
565         for (EnumPair enumPair : enumPairs) {
566             enumNames.add(enumPair.getName());
567         }
568         property.putOpt(ENUM, new JSONArray(enumNames));
569     }
570
571     /**
572      *
573      * @param bitsType
574      * @param property
575      * @throws JSONException
576      */
577     private void processBitsType(BitsTypeDefinition bitsType, JSONObject property)
578             throws JSONException {
579         property.put(TYPE_KEY, ARRAY_TYPE);
580         property.put(MIN_ITEMS, 0);
581         property.put(UNIQUE_ITEMS_KEY, true);
582         JSONArray enumValues = new JSONArray();
583
584         List<Bit> bits = bitsType.getBits();
585         for (Bit bit : bits) {
586             enumValues.put(bit.getName());
587         }
588         JSONObject itemsValue = new JSONObject();
589         itemsValue.put(ENUM, enumValues);
590         property.put(ITEMS_KEY, itemsValue);
591     }
592
593     /**
594      *
595      * @param unionType
596      * @param property
597      * @throws JSONException
598      */
599     private void processUnionType(UnionTypeDefinition unionType, JSONObject property)
600             throws JSONException {
601
602         StringBuilder type = new StringBuilder();
603         for (TypeDefinition<?> typeDef : unionType.getTypes() ) {
604             if( type.length() > 0 ){
605                 type.append( " or " );
606             }
607             type.append(YANG_TYPE_TO_JSON_TYPE_MAPPING.get(typeDef.getClass()));
608         }
609
610         property.put(TYPE_KEY, type );
611     }
612
613     /**
614      * Helper method to generate a pre-filled JSON schema object.
615      *
616      * @return
617      * @throws JSONException
618      */
619     private JSONObject getSchemaTemplate() throws JSONException {
620         JSONObject schemaJSON = new JSONObject();
621         schemaJSON.put(SCHEMA_KEY, SCHEMA_URL);
622
623         return schemaJSON;
624     }
625 }