Revert - we'll do this in Smile
This commit is contained in:
parent
7734e8f515
commit
10d4db5b9e
|
@ -126,20 +126,11 @@ public class OpenApiInterceptor {
|
||||||
private final Map<String, String> myResourcePathToClasspath = new HashMap<>();
|
private final Map<String, String> myResourcePathToClasspath = new HashMap<>();
|
||||||
private final Map<String, String> myExtensionToContentType = new HashMap<>();
|
private final Map<String, String> myExtensionToContentType = new HashMap<>();
|
||||||
private String myBannerImage;
|
private String myBannerImage;
|
||||||
private final boolean myShowPartitionPrefix;
|
|
||||||
|
|
||||||
// FIXME KZ delete this? Or figure out a better way to pass the configuration in.
|
|
||||||
public OpenApiInterceptor() {
|
|
||||||
this(false,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public OpenApiInterceptor(boolean theRequestPartitionFlag, String theDefaultPartitionName) {
|
public OpenApiInterceptor() {
|
||||||
// FIXME MB how to configure? Do we know the default partition name?
|
|
||||||
myShowPartitionPrefix = theRequestPartitionFlag;
|
|
||||||
|
|
||||||
mySwaggerUiVersion = initSwaggerUiWebJar();
|
mySwaggerUiVersion = initSwaggerUiWebJar();
|
||||||
|
|
||||||
myTemplateEngine = new TemplateEngine();
|
myTemplateEngine = new TemplateEngine();
|
||||||
|
@ -752,19 +743,9 @@ public class OpenApiInterceptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Operation getPathItem(Paths thePaths, String thePath, PathItem.HttpMethod theMethod) {
|
protected Operation getPathItem(Paths thePaths, String thePath, PathItem.HttpMethod theMethod) {
|
||||||
PathItem pathItem;
|
PathItem pathItem;
|
||||||
String partitionPrefix;
|
|
||||||
|
|
||||||
Operation newOperation = new Operation();
|
|
||||||
|
|
||||||
if (myShowPartitionPrefix) {
|
|
||||||
partitionPrefix = "/{partitionId}";
|
|
||||||
addPartitionNameParameter(newOperation);
|
|
||||||
} else {
|
|
||||||
partitionPrefix = "";
|
|
||||||
}
|
|
||||||
thePath = partitionPrefix + thePath;
|
|
||||||
if (thePaths.containsKey(thePath)) {
|
if (thePaths.containsKey(thePath)) {
|
||||||
pathItem = thePaths.get(thePath);
|
pathItem = thePaths.get(thePath);
|
||||||
} else {
|
} else {
|
||||||
|
@ -775,19 +756,19 @@ public class OpenApiInterceptor {
|
||||||
switch (theMethod) {
|
switch (theMethod) {
|
||||||
case POST:
|
case POST:
|
||||||
assert pathItem.getPost() == null : "Have duplicate POST at path: " + thePath;
|
assert pathItem.getPost() == null : "Have duplicate POST at path: " + thePath;
|
||||||
return pathItem.post(newOperation).getPost();
|
return pathItem.post(new Operation()).getPost();
|
||||||
case GET:
|
case GET:
|
||||||
assert pathItem.getGet() == null : "Have duplicate GET at path: " + thePath;
|
assert pathItem.getGet() == null : "Have duplicate GET at path: " + thePath;
|
||||||
return pathItem.get(newOperation).getGet();
|
return pathItem.get(new Operation()).getGet();
|
||||||
case PUT:
|
case PUT:
|
||||||
assert pathItem.getPut() == null;
|
assert pathItem.getPut() == null;
|
||||||
return pathItem.put(newOperation).getPut();
|
return pathItem.put(new Operation()).getPut();
|
||||||
case PATCH:
|
case PATCH:
|
||||||
assert pathItem.getPatch() == null;
|
assert pathItem.getPatch() == null;
|
||||||
return pathItem.patch(newOperation).getPatch();
|
return pathItem.patch(new Operation()).getPatch();
|
||||||
case DELETE:
|
case DELETE:
|
||||||
assert pathItem.getDelete() == null;
|
assert pathItem.getDelete() == null;
|
||||||
return pathItem.delete(newOperation).getDelete();
|
return pathItem.delete(new Operation()).getDelete();
|
||||||
case HEAD:
|
case HEAD:
|
||||||
case OPTIONS:
|
case OPTIONS:
|
||||||
case TRACE:
|
case TRACE:
|
||||||
|
@ -864,18 +845,6 @@ public class OpenApiInterceptor {
|
||||||
theOperation.addParametersItem(parameter);
|
theOperation.addParametersItem(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPartitionNameParameter(Operation theOperation) {
|
|
||||||
Parameter parameter = new Parameter();
|
|
||||||
parameter.setName("partition_name");
|
|
||||||
// FIXME MB only if request mode
|
|
||||||
parameter.setIn("path");
|
|
||||||
parameter.setDescription("The name of the partition to target");
|
|
||||||
parameter.setExample("DEFAULT");
|
|
||||||
parameter.setSchema(new Schema().type("string").minimum(new BigDecimal(1)));
|
|
||||||
parameter.setStyle(Parameter.StyleEnum.SIMPLE);
|
|
||||||
theOperation.addParametersItem(parameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ClassLoaderTemplateResource getIndexTemplate() {
|
protected ClassLoaderTemplateResource getIndexTemplate() {
|
||||||
return new ClassLoaderTemplateResource(myResourcePathToClasspath.get("/swagger-ui/index.html"), StandardCharsets.UTF_8.name());
|
return new ClassLoaderTemplateResource(myResourcePathToClasspath.get("/swagger-ui/index.html"), StandardCharsets.UTF_8.name());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue