Beispiel #1
0
  @Override
  public void generateDocumentation(Writer writer, String serverPrefix, Locale locale) {
    LOGGER.info("Generating REST documentation");

    SwaggerModel swaggerModel = initialSwaggerModel(serverPrefix, locale);
    swaggerModel.addDefinition("Metadata", buildMetadataDefinition());

    for (Entity entity : allEntities.retrieveAll()) {
      addCrudEndpoints(swaggerModel, entity, locale);
      addLookupEndpoints(swaggerModel, entity, locale);
      addDefinitions(swaggerModel, entity);
    }

    if (swaggerModel.getDefinitions().size() == 1) {
      swaggerModel
          .getInfo()
          .setDescription(
              String.format(
                  "%s \n\n**%s [%s](%s)**",
                  msg(locale, API_DESCRIPTION_KEY),
                  msg(locale, NO_ENTITY_IS_EXPOSED_KEY),
                  msg(locale, REST_API_DOCS_KEY),
                  property(REST_API_DOCS_URL_KEY)));
    }

    Gson gson = buildGson();

    gson.toJson(swaggerModel, writer);
  }
 private ImportExportBlueprint sortBlueprintRecords(ImportExportBlueprint blueprint) {
   List<Entity> entities = new ArrayList<>(blueprint.size());
   for (ImportExportBlueprint.Record record : blueprint) {
     entities.add(allEntities.retrieveByClassName(record.getEntityName()));
   }
   RelationshipSorter relationshipSorter = new RelationshipSorter();
   relationshipSorter.sort(entities);
   ImportExportBlueprint sortedBlueprint = new ImportExportBlueprint();
   for (Entity entity : entities) {
     String entityName = entity.getClassName();
     sortedBlueprint.includeEntitySchema(entityName, blueprint.isIncludeEntitySchema(entityName));
     sortedBlueprint.includeEntityData(entityName, blueprint.isIncludeEntityData(entityName));
   }
   return sortedBlueprint;
 }
Beispiel #3
0
 private Field getRelatedField(String entityClassName, String fieldName) {
   Entity entity = allEntities.retrieveByClassName(entityClassName);
   return entity.getField(fieldName);
 }