Revert - we'll do this in Smile

This commit is contained in:
Michael Buckley 2021-08-20 17:21:07 -04:00
parent 7734e8f515
commit 10d4db5b9e
1 changed files with 7 additions and 38 deletions

View File

@ -126,20 +126,11 @@ public class OpenApiInterceptor {
private final Map<String, String> myResourcePathToClasspath = new HashMap<>();
private final Map<String, String> myExtensionToContentType = new HashMap<>();
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
*/
public OpenApiInterceptor(boolean theRequestPartitionFlag, String theDefaultPartitionName) {
// FIXME MB how to configure? Do we know the default partition name?
myShowPartitionPrefix = theRequestPartitionFlag;
public OpenApiInterceptor() {
mySwaggerUiVersion = initSwaggerUiWebJar();
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;
String partitionPrefix;
Operation newOperation = new Operation();
if (myShowPartitionPrefix) {
partitionPrefix = "/{partitionId}";
addPartitionNameParameter(newOperation);
} else {
partitionPrefix = "";
}
thePath = partitionPrefix + thePath;
if (thePaths.containsKey(thePath)) {
pathItem = thePaths.get(thePath);
} else {
@ -775,19 +756,19 @@ public class OpenApiInterceptor {
switch (theMethod) {
case POST:
assert pathItem.getPost() == null : "Have duplicate POST at path: " + thePath;
return pathItem.post(newOperation).getPost();
return pathItem.post(new Operation()).getPost();
case GET:
assert pathItem.getGet() == null : "Have duplicate GET at path: " + thePath;
return pathItem.get(newOperation).getGet();
return pathItem.get(new Operation()).getGet();
case PUT:
assert pathItem.getPut() == null;
return pathItem.put(newOperation).getPut();
return pathItem.put(new Operation()).getPut();
case PATCH:
assert pathItem.getPatch() == null;
return pathItem.patch(newOperation).getPatch();
return pathItem.patch(new Operation()).getPatch();
case DELETE:
assert pathItem.getDelete() == null;
return pathItem.delete(newOperation).getDelete();
return pathItem.delete(new Operation()).getDelete();
case HEAD:
case OPTIONS:
case TRACE:
@ -864,18 +845,6 @@ public class OpenApiInterceptor {
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() {
return new ClassLoaderTemplateResource(myResourcePathToClasspath.get("/swagger-ui/index.html"), StandardCharsets.UTF_8.name());
}