Package org.codehaus.enunciate.contract.json

Examples of org.codehaus.enunciate.contract.json.JsonTypeDefinition


          loadTypeDef(typeDef, model);
        }

        boolean jsonType = isPotentialJsonSchemaType(declaration);
        if (jsonType) {
          JsonTypeDefinition typeDefinition = JsonTypeDefinition.createTypeDefinition((ClassDeclaration) declaration);
          loadJsonTypeDef(typeDefinition, model);
        }

        if (!xmlType && !jsonType) {
          onUnhandledDeclaration(model, declaration);
View Full Code Here


    return null;
  }

  private JsonSchemaInfo jsonSchemaForType(final JsonType jsonType) {
    if (jsonType instanceof JsonTypeDefinition) {
      final JsonTypeDefinition jsonTypeDefinition = (JsonTypeDefinition) jsonType;
      final String schemaId = JsonSchemaInfo.schemaIdForType(jsonTypeDefinition.classDeclaration());
      return model.getIdsToJsonSchemas().get(schemaId);
    }
    return null;
  }
View Full Code Here

   */
  public void testAddJsonTypeDefinition()
  {
      EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
      FreemarkerModel.set(model);
      final JsonTypeDefinition nameTypeDefinition = JsonTypeDefinition.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.json.Name"));
      assertNull(model.findJsonTypeDefinition(nameTypeDefinition));
      model.addJsonType(nameTypeDefinition);
      assertNotNull(model.findJsonTypeDefinition(nameTypeDefinition));
      JsonSchemaInfo jsonSchemaInfo = model.getIdsToJsonSchemas().get(JsonSchemaInfo.schemaIdForType(nameTypeDefinition));
      assertNotNull(jsonSchemaInfo);
      assertNotNull(jsonSchemaInfo.getTypesByName().get(nameTypeDefinition.getTypeName()));
      assertNull(jsonSchemaInfo.getTopLevelTypesByName().get(nameTypeDefinition.getTypeName()));
  }
View Full Code Here

  public void testAddJsonRootElement()
  {
      EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
      FreemarkerModel.set(model);

      final JsonTypeDefinition nameTypeDefinition = JsonTypeDefinition.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.json.Name"));
      final JsonRootElementDeclaration rootElementDeclaration = new JsonRootElementDeclaration(nameTypeDefinition);

      assertNull(model.findJsonRootElementDeclaration(rootElementDeclaration));
      model.addJsonRootElement(rootElementDeclaration);
      assertNotNull(model.findJsonRootElementDeclaration(rootElementDeclaration));
      assertNotNull(model.findJsonTypeDefinition(nameTypeDefinition));

      JsonSchemaInfo jsonSchemaInfo = model.getIdsToJsonSchemas().get(JsonSchemaInfo.schemaIdForType(nameTypeDefinition));
      assertNotNull(jsonSchemaInfo);
      assertNotNull(jsonSchemaInfo.getTypesByName().get(nameTypeDefinition.getTypeName()));
      assertNotNull(jsonSchemaInfo.getTopLevelTypesByName().get(nameTypeDefinition.getTypeName()));
  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.contract.json.JsonTypeDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.