use of org.apache.knox.gateway.service.definition.Sample in project knox by apache.
the class ServiceModel method getSamples.
@XmlElement(name = "sample")
@XmlElementWrapper(name = "samples")
public List<Sample> getSamples() {
final List<Sample> samples = new ArrayList<>();
if (serviceMetadata != null && serviceMetadata.getSamples() != null) {
serviceMetadata.getSamples().forEach(sample -> {
final Sample resolvedSample = new Sample();
resolvedSample.setDescription(sample.getDescription());
if (StringUtils.isNotBlank(sample.getValue())) {
resolvedSample.setValue(sample.getValue());
} else {
final String method = StringUtils.isBlank(sample.getMethod()) ? "GET" : sample.getMethod();
resolvedSample.setValue(String.format(Locale.ROOT, CURL_SAMPLE_TEMPLATE, method, getServiceUrl(), sample.getPath()));
}
samples.add(resolvedSample);
});
}
return samples;
}
Aggregations