小编Not*_*one的帖子

重用具有不同所需属性的模型

我有一个路径,它使用每个http方法具有几乎相同属性的复杂模型.问题是我想为PUT和POST的请求定义一些必需的属性,而GET响应中不需要属性(因为服务器总是返回所有属性,并且在文档的其他地方提到它).

我创建了一个简单的cat API来演示我尝试过的东西.我们的想法是,对于GET响应,响应模型没有标记为必需的任何内容,但PUT的请求必须具有猫的名称.

swagger: "2.0"

info:
  title: "Cat API"
  version: 1.0.0

paths:
  /cats/{id}:
    parameters:
      - name: id
        in: path
        required: true
        type: integer
    get:
      responses:
        200:
          description: Return a cat
          schema:
            $ref: "#/definitions/GetCat"
    put:
      parameters:
        - name: cat
          in: body
          required: true
          schema:
            $ref: "#/definitions/PutCat"
      responses:
        204:
          description: Cat edited

definitions:
  Cat:
    type: object
    properties:
      name:
        type: string
  GetCat:
    allOf:
      - $ref: "#/definitions/Cat"
    properties:
      id:
        type: integer
  PutCat:
    type: object
    required:
      - name
    properties:
      $ref: "#/definitions/Cat/properties"
Run Code Online (Sandbox Code Playgroud)

Swagger编辑说这是一个有效的规范,但是name …

swagger openapi

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

matplotlib:如何拿起班次点击数字?

我有一个matplotlib,我创建了button_press_event这样的:

self.fig.canvas.mpl_connect('button_press_event', self.onClick)

def onClick(self, event)
    if event.button == 1:
        # draw some artists on left click

    elif event.button == 2:
        # draw a vertical line on the mouse x location on wheel click

    elif event.button == 3:
        # clear artists on right click
Run Code Online (Sandbox Code Playgroud)

现在可以将车轮点击处理程序修改为这样的东西

    elif event.button == 2 or (event.button == 1 and event.key == "shift"):
        # draw a vertical line on the mouse x location 
        # on wheel click or on shift+left click 
        # (alternative way …
Run Code Online (Sandbox Code Playgroud)

python matplotlib shift mouseevent modifier-key

6
推荐指数
1
解决办法
3182
查看次数

标签 统计

matplotlib ×1

modifier-key ×1

mouseevent ×1

openapi ×1

python ×1

shift ×1

swagger ×1