Comparison

mod_rest/apidemo.lib.lua @ 4550:0befc680970b

mod_rest/apidemo: Disable validator How nice of them to leak the URL of every schema to them by default.
author Kim Alvefur <zash@zash.se>
date Sun, 25 Apr 2021 17:09:22 +0200
parent 4528:fd15e7f00ff5
child 4728:1c6d353550cc
comparison
equal deleted inserted replaced
4549:cce0e1ec8a74 4550:0befc680970b
15 index = f:read("*a"); 15 index = f:read("*a");
16 f:close(); 16 f:close();
17 17
18 -- SUCH HACK, VERY GSUB, WOW! 18 -- SUCH HACK, VERY GSUB, WOW!
19 index = index:gsub("(%s?url%s*:%s*)%b\"\"", string.format("%%1%q", module:http_url().."/demo/openapi.yaml"), 1); 19 index = index:gsub("(%s?url%s*:%s*)%b\"\"", string.format("%%1%q", module:http_url().."/demo/openapi.yaml"), 1);
20 index = index:gsub("(%s*SwaggerUIBundle%s*%(%s*{)(%s*)", "%1%2validatorUrl: false,%2");
20 end 21 end
21 22
22 do 23 do
23 local f = module:load_resource("res/openapi.yaml"); 24 local f = module:load_resource("res/openapi.yaml");
24 _M.schema = { 25 _M.schema = {
38 }; 39 };
39 40
40 _M.main_page = { 41 _M.main_page = {
41 headers = { 42 headers = {
42 content_type = "text/html"; 43 content_type = "text/html";
44 content_security_policy = "default-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; frame-ancestors 'none'";
43 }; 45 };
44 body = index; 46 body = index;
45 } 47 }
46 48
47 return _M 49 return _M