小编sn0*_*0rk的帖子

如何覆盖 openapi 中的示例?

我有响应结构:

responses:
  '200':
    description: OK
    content:
      application/json:
        schema:
          type: object
          properties:
            data:
              allOf:
              - { $ref: ../../components/schemas/Product.yaml }
              example:
                active: false
Run Code Online (Sandbox Code Playgroud)

还有 Product.yaml 之一:

type: object
description: Product
properties:
  id:
    description: ID
    type: integer
    example: 1
  name:
    description: Name
    type: string
    example: 'fresh baguette'
  active:
    description: Is active
    type: boolean
    example: true
Run Code Online (Sandbox Code Playgroud)

所以我想覆盖活动示例,当我这样做时:

data:
  allOf:
  - { $ref: ../../components/schemas/Product.yaml }
  example:
    active: false
Run Code Online (Sandbox Code Playgroud)

在“响应示例”下的 redoc ui 中,我看到唯一的活动属性。

我的问题是如何在不覆盖每个产品属性的情况下覆盖仅活动属性的示例?

swagger openapi

5
推荐指数
1
解决办法
5951
查看次数

如何忽略 go.mod 中的替换指令

我在进行本地开发时使用“替换”语句。所以我的 go.mod 看起来像这样:

require (
 gorm.io/gorm v1.21.11
 github.com/mypackages/session v1.1.0
)

replace (
 github.com/mypackages/session => ./../session
)
Run Code Online (Sandbox Code Playgroud)

但是当git commit我更改并将代码部署到生产时,我不需要“替换” ,所以我需要在每个替换代码上注释这行替换代码,git commit然后取消注释。有没有办法忽略生产环境中的“替换”语句?

go go-modules

2
推荐指数
2
解决办法
80
查看次数

标签 统计

go ×1

go-modules ×1

openapi ×1

swagger ×1