
net.cpollet.maven.plugins.postman.backend.adapters.ClassAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of postman-maven-plugin Show documentation
Show all versions of postman-maven-plugin Show documentation
A maven plugin to export JAX-RS annotated classes and methods to Postman collection
The newest version!
package net.cpollet.maven.plugins.postman.backend.adapters;
import lombok.AllArgsConstructor;
import net.cpollet.maven.plugins.postman.frontend.api.Endpoint;
import javax.ws.rs.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@AllArgsConstructor
public class ClassAdapter {
private final Class> clazz;
public List getEndpoints() {
return Collections.unmodifiableList(
Arrays.stream(clazz.getMethods())
.map(MethodAdapter::new)
.filter(MethodAdapter::isHttpEndpoint)
.map(m -> new Endpoint(
clazz.getSimpleName(),
m.getName(),
m.getVerb(),
getPath() + m.getPath(),
m.getBodyParameterType(),
m.getQueryParametersNames(),
m.getResponseType()
))
.collect(Collectors.toList())
);
}
private String getPath() {
return new PathAdapter(clazz.getAnnotation(Path.class)).getPath();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy