GCP 端点中的 openapi-run.yaml "Unable to load RELATIVE ref"



我使用Google Cloud Build来构建依赖于openapi-run.yaml来定义API的GCP端点。我有一个很大的JSON模式文件,我想在openapi-run.yaml中引用它:

/testRef:
get:
summary: test for Reference
operationId: testRef
responses:
'200':
description: A successful response
schema: 
$ref: "/workspace/src/models/myLargeSchema.json#/Account"  

但是当我运行gcloud endpoints services deploy openapi-run.yaml --project myProject时,它给了我一个错误的说法"OpenAPI spec in file {openapi-run.yaml} is ill formed and cannot be parsed: Unable to load RELATIVE ref: /workspace/src/models/myLargeSchema.json"

我使用ls命令仔细检查并确认模式文件是可检索的:

- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args: [ '-c', 'ls ./src/models -la']

Step #0: drwxr-xr-x  2 501 dialout    4096 Jan 27 13:12 .
Step #0: drwxr-xr-x 15 501 dialout    4096 Dec  6 22:53 ..
Step #0: -rw-r--r--  1 501 dialout    2912 Dec 31 11:30 JSONSchemaValidator.ts
Step #0: -rw-r--r--  1 501 dialout 3370813 Jan 27 13:12 myLargeSchema.json
Step #0: -rw-r--r--  1 501 dialout     539 Dec 19 19:58 user.ts

我怎么能写我的openapi-run.yaml,使它可以引用我的JSON模式在另一个文件?

我发现在NOT中调用外部引用GCP端点支持:https://cloud.google.com/endpoints/docs/openapi/openapi-limitations#external_type_references

使用的是绝对文件名,而不是相对文件名。尝试从$ref的路径中删除前面的/workspace/

相关内容

最新更新