如何从loopback应用中删除所有前端文件
在回环API开发时,默认 LP4 App
命令非常方便地生成一个带有Swagger API Explorer的简单着陆页。
但是我不想完成这个。在代码中,我在哪里禁用自托管页面,以及我应该删除哪些文件以删除项目中的无关文件?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有 4 您可能需要单独禁用/删除的工件:
/
登录页面:链接到OpenAPI的默认页面.json
和API资源管理器。/Swagger>/Swagger-ui
和/explorer
重定向到托管在其他地方的REST Explorer(例如=“ https://explorer.loopback.io” rel =“ nofollow noreferrer”> https://explorer.loopback.io )。/explorer
提供的REST Explorer。默认情况下,优先考虑/explorer
路径的托管REST Explorer重定向。/popenapi.json
默认情况下。尽管可以完全遵循此处的说明,以便在大多数Loopback 4项目中都遵循,但更多的定制项目可能会有某些内容(例如应用程序或组件配置)。
删除默认
/
着陆页:删除
public
目录从
src/application.ts
:中删除以下行
以通过配置禁用外部托管的REST Explorer:
src/index.ts ,配置
config.rest.apiexplorer.disabled
:完全删除自托管REST Explorer:
删除以下来自
application.ts
的行:application.ts
通过配置禁用OpenAPI Spec端点:
in
src/index.ts.ts
,配置config.rest.openapispec.disabled
:请注意,禁用OpenAPI规格端点会阻止REST Exploter在依赖其依赖的情况下正常工作Web浏览器可访问的OpenAPI规格。
禁用Opanapi Spec端点不会从TypeScript中禁用对OpenAPI规格的访问,也不会影响AJV验证。
参考
There are 4 artifacts that you may want to individually disabled/removed:
/
landing page: The default page that links toopenapi.json
and the API explorer./swagger-ui
and/explorer
to a REST explorer that's hosted elsewhere (e.g. https://explorer.loopback.io)./explorer
. Takes precedence over hosted REST explorer redirect for/explorer
path by default./openapi.json
by default.Although the instructions here can be followed exactly for majority of LoopBack 4 projects, more customised projects may have certain things (e.g. application or component configuration) moved around.
To remove the default
/
landing page:Remove the
public
directoryRemove the following lines from
src/application.ts
:To disable externally-hosted REST explorer through configuration:
In
src/index.ts
, configureconfig.rest.apiExplorer.disabled
:To completely remove self-hosted REST explorer:
Remove the following lines from
application.ts
:Uninstall
@loopback/rest-explorer
To disable the OpenAPI spec endpoint through configuration:
In
src/index.ts
, configureconfig.rest.openApiSpec.disabled
:Note that disabling the OpenAPI spec endpoint would prevent the REST explorers from working correctly as they are dependent on an web browser-accessible OpenAPI spec.
Disabling the OpanAPI spec endpoint does not disable access to the OpenAPI spec from within TypeScript nor does it affect AJV validation.
References