Ejemplo n.º 1
0
  private List<Parameter> lookupParameters(Entity entity, Lookup lookup, Locale locale) {
    List<Parameter> parameters = new ArrayList<>();

    for (String lookupFieldName : lookup.getFieldsOrder()) {
      LookupFieldType lookupFieldType = lookup.getLookupFieldType(lookupFieldName);
      Field lookupField;
      if (lookupFieldName.contains(".")) {
        lookupField =
            getRelatedField(
                lookup
                    .getLookupFieldByName(LookupName.getFieldName(lookupFieldName))
                    .getMetadata(Constants.MetadataKeys.RELATED_CLASS)
                    .getValue(),
                LookupName.getRelatedFieldName(lookupFieldName));
      } else {
        lookupField = lookup.getLookupFieldByName(lookupFieldName);
      }
      String paramDesc = lookupParamDescription(lookupField, lookupFieldType, locale);

      Parameter parameter =
          SwaggerFieldConverter.lookupParameter(
              lookupFieldName, lookupField, lookupFieldType, paramDesc);
      parameters.add(parameter);
    }

    parameters.addAll(queryParamsParameters(entity.getFieldsExposedByRest(), locale));

    return parameters;
  }
Ejemplo n.º 2
0
  private PathEntry readPathEntry(Entity entity, Locale locale) {
    final PathEntry pathEntry = new PathEntry();

    final String entityName = entity.getName();

    pathEntry.setDescription(msg(locale, READ_DESC_KEY, entityName));
    pathEntry.setOperationId(msg(locale, READ_ID_KEY, entityName));
    pathEntry.setProduces(json());
    pathEntry.addTag(entity.getClassName());

    pathEntry.setParameters(queryParamsParameters(entity.getFieldsExposedByRest(), locale));
    pathEntry.addParameter(idQueryParameter(locale));

    pathEntry.addResponse(HttpStatus.OK, readResponse(entity, locale));
    addCommonResponses(pathEntry, locale);

    return pathEntry;
  }