Meta data / API document

        By default, this view func will return API document(HTML),
        you can set request header `Accept` to `application/json`
        or set query string `json` to get meta data(JSON).

def meta_view(self):
        """
        Meta data / API document

        By default, this view func will return API document(HTML),
        you can set request header `Accept` to `application/json`
        or set query string `json` to get meta data(JSON).
        """
        # API_URL_PREFIX maybe diffierent in development and production,
        # so pick it from app.config other than store it in metafile
        self.meta["$url_prefix"] = current_app.config.get("API_URL_PREFIX", "")
        mediatype = request.accept_mimetypes.best_match(
            ['text/html', 'application/json'], default='text/html')
        dumped = json.dumps(
            self.meta, indent=4, sort_keys=True, ensure_ascii=False)
        if mediatype == 'application/json' or 'json' in request.args:
            return make_response(dumped, {
                "Content-Type": "application/json; charset=utf-8"
            })
        filename = request.args.get('f')
        if filename in ["res.js", "res.min.js"]:
            # cache parsed meta
            if self._resjs_cache is None:
                self._resjs_cache = parse_meta(self.meta)
            minify = filename == "res.min.js"
            code = generate_code(self._resjs_cache,
                                 prefix=self.meta["$url_prefix"], min=minify)
            response = make_response(code, {
                "Content-Type": "application/javascript"
            })
            # handle etag
            response.add_etag()
            return response.make_conditional(request)
        if filename:
            return send_from_directory(DOCS_DIST, basename(filename))
        with open(DOCS_HTML) as f:
            content = f.read()\
                .replace('$(title)', self.meta.get('$title', ''))\
                .replace('$(meta)', dumped)
        return make_response(content)