docs: def publish_apis(self, path='doc'):
          """Publish all loaded apis on under the uri /<path>/<api-name>, by
          redirecting to http://petstore.swagger.io/
          """
  
          assert path
  
          if not self.apis:
              raise Exception("You must call .load_apis() before .publish_apis()")
  
          # Infer the live host url from pym-config.yaml
          proto = 'http'
          if hasattr(get_config(), 'aws_cert_arn'):
              proto = 'https'
  
          live_host = "%s://%s" % (proto, get_config().live_host)
  
          # Allow cross-origin calls
          CORS(self.app, resources={r"/%s/*" % path: {"origins": "*"}})
  
          # Add routes to serve api specs and redirect to petstore ui for each one
          for api_name, api_path in self.apis.items():
  
              api_filename = os.path.basename(api_path)
              log.info("Publishing api %s at /%s/%s" % (api_name, path, api_name))
  
              def redirect_to_petstore(live_host, api_filename):
                  def f():
                      url = 'http://petstore.swagger.io/?url=%s/%s/%s' % (live_host, path, api_filename)
                      log.info("Redirecting to %s" % url)
                      return redirect(url, code=302)
                  return f
  
              def serve_api_spec(api_path):
                  def f():
                      with open(api_path, 'r') as f:
                          spec = f.read()
                          log.info("Serving %s" % api_path)
                          return Response(spec, mimetype='text/plain')
                  return f
  
              self.app.add_url_rule('/%s/%s' % (path, api_name), str(uuid4()), redirect_to_petstore(live_host, api_filename))
              self.app.add_url_rule('/%s/%s' % (path, api_filename), str(uuid4()), serve_api_spec(api_path))
  
          return self