swagger 编辑器 - 通过 URL 一次显示多个文件

问题描述 投票:0回答:1

按照此处的文档进行操作:https://github.com/swagger-api/swagger-editor?tab=readme-ov-file#docker

我看到有一种方法可以用你自己的文件运行 swagger 编辑器

docker run -d -p 80:8080 -v $(pwd):/tmp -e SWAGGER_FILE=/tmp/swagger.json swaggerapi/swagger-editor

然后当您导航到本地主机时,您将看到显示 swagger.json

有没有办法让这种情况动态发生,而不是在每个 docker run 构建上发生。例如

localhost/swagger 与 localhost/swagger2 将显示 2 个不同的 swagger 文件,而我不需要为此执行 2 个 docker run 命令。

docker swagger-editor
1个回答
0
投票

我发现你可以在 swagger ui 和 swagger editor 中执行此操作,但不能使用 swagger next 。您需要将环境变量传递给 docker run。

swagger-ui:

docker pull swaggerapi/swagger-ui
docker run -p 80:8080 -e QUERY_CONFIG_ENABLED=true swaggerapi/swagger-ui

http://localhost/?url=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/api-with-examples.yaml - 有效

招摇编辑:

docker pull swaggerapi/swagger-editor
docker run -p 80:8080 -e QUERY_CONFIG_ENABLED=true swaggerapi/swagger-editor

http://localhost/?url=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/api-with-examples.yaml-works

swagger-编辑器下一个

docker pull swaggerapi/swagger-editor:next-v5
docker run -d -p 8080:80 swaggerapi/swagger-editor:next-v5 

http://localhost:8080/?url=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/api-with-examples.yaml - 不起作用

docker pull swaggerapi/swagger-editor:next-v5
docker run -d -p 8080:80 -e QUERY_CONFIG_ENABLED=true swaggerapi/swagger-editor:next-v5 

http://localhost:8080/?url=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/api-with-examples.yaml - 不起作用

© www.soinside.com 2019 - 2024. All rights reserved.