我使用swagger UI来记录API。我已经使用docker部署了Ui和节点服务器(具有JSON)。部署后,当我在JSON文件中进行更改时,除非刷新整个页面,否则不会在swagger-UI中反映相同的内容。
我尝试在swagger-ui的index.html中添加<html manifest="example.appcache">,清单文件具有以下配置
CACHE MANIFEST
NETWORK:
*即使在设置了清单之后,JSON仍然会从缓存中加载。有人能帮帮忙吗。
发布于 2020-03-23 16:52:36
在Swagger repository issues上有一些讨论和一些解决方案,比如创建一个请求拦截器,并在发送请求之前设置头部:
var interceptor = {
requestInterceptor: {
apply: function (requestObj) {
var headers = request.Obj.headers || {};
headers['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
headers['Cache-Control'] = 'no-cache';
headers['Pragma'] = 'no-cache';
return requestObj;
}
}
};
// assign the request interceptor in the UI
new SwaggerClient({
url: 'http://localhost:8000/v2/petstore.json',
requestInterceptor: interceptor.requestInterceptor,https://stackoverflow.com/questions/38480271
复制相似问题