如何在OpenAPI 3.0.3中隐藏一个字段

发布于 2025-02-04 05:45:04 字数 1081 浏览 3 评论 0原文

我创建了一个包含一个get和apt的摇摇欲坠,第一个在我称之为元素(“ mycar”)的情况下,第二个我更新了车牌。作为一个相同的对象,我如何确保在招摇中只能显示板而不是对象的所有字段?

  '/example/car/{carId}':
get:
  summary: Get a Car by Id
  description: Get a car
  operationId: getCar
  tags:
    - Car
  parameters:
    - in: path
      name: carId
      required: true
      description: carID
      schema:
        type: string
  responses:
    '200':
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MyCar'
[...]
put:
  summary: Update car plate
  description: update a plate by carID
  operationId: updatePlate
  tags:
    - Car
  parameters:
    - in: path
      name: carId
      required: true
      description: CarID to save
      schema:
        type: string
  requestBody:
    description: The new plate to create
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/MyCar'
[...]
 MyCar:
  type: object
  properties:
    id:
      type: string
    owner:
      type: string
    plate:
      type: string

有没有办法仅显示前牌中的车牌而没有显示整个对象?

I created a swagger containing a get and a put, where in the first I call an element ("MyCar") and in the second I update the license plate. Being the same object, how can I make sure that in the swagger put it can show only the plate instead of all the fields of the object?

  '/example/car/{carId}':
get:
  summary: Get a Car by Id
  description: Get a car
  operationId: getCar
  tags:
    - Car
  parameters:
    - in: path
      name: carId
      required: true
      description: carID
      schema:
        type: string
  responses:
    '200':
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MyCar'
[...]
put:
  summary: Update car plate
  description: update a plate by carID
  operationId: updatePlate
  tags:
    - Car
  parameters:
    - in: path
      name: carId
      required: true
      description: CarID to save
      schema:
        type: string
  requestBody:
    description: The new plate to create
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/MyCar'
[...]
 MyCar:
  type: object
  properties:
    id:
      type: string
    owner:
      type: string
    plate:
      type: string

is there a way to show only the license plate in the put without showing the whole object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文