【问题标题】:Is it possible to hide the file name of a ref when used in schema definition?在模式定义中使用时是否可以隐藏 ref 的文件名?
【发布时间】:2022-11-17 19:23:49
【问题描述】:

我的 openapi.yml 文件端点如下所示:

/v2/myendpoint:
  get:
    summary: Retrieve stuff
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../schemas/my_get_request.json'

在 my_get_request.json 中,我引用了 common.json 文件中的定义。

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://january.com/schemas/v0.2.1/my_get_request.json",
    "type": "object",
    "title": "MyGetRequest",
    "properties": {
        "unique_ID": {
            "type": "string",
            "description": "randomdescription"
        },
        "status": {
            "$ref": "common.json#/$defs/blahStatus"
        },

当我使用 Redocly 生成静态网页时,在 status 旁边我看到 string(blahStatus) 是否可以隐藏 string(blahStatus) 不显示以便用户看不到我在 common.json 中定义的内部命名?

【问题讨论】:

    标签: openapi redoc


    【解决方案1】:

    如果这个问题仍然合法,解决方案是使用 ReDoc CLI 的 hideSchemaTitles 选项。

    hideSchemaTitles - do not display schema title next to to the type
    

    请参阅https://github.com/Redocly/redoc#redoc-options-object 以供参考。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 2010-10-21
      • 1970-01-01
      • 2019-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多