2016-07-25 4 views
0

私はかなり面白いです。スワッガーは「有効なパラメータのデフェネーションではありません」と答えています

私は一緒にテストプロジェクトを持っており、いくつかの問題に取り組んでいます。

「削除」ブロックの「パラメータ」が無効であるというエラーが表示されます。私は例で見たことから私にはうまく見えます。しかし、明らかに私は何かを欠いている。何か案は?

swagger: "2.0" 

info: 
    version: "2" 
    title: My Title 
    description: Provides services for vacation rentals site 
    termsOfService: Private 
    contact: 
    name: My Name 
    url: www.myurl.com 
    email: [email protected] 
    license: 
    name: MIT 
    url: http://opensource.org/licenses/MIT 
schemes: 
    - http 
host: myurl.com 
basePath: /api 

paths: 
    /guestbook: 
    get: 
     summary: Gets some persons 
     description: Returns a list containing all persons. 
     responses: 
     200: 
      description: A list of posts 
      schema: 
      type: array 
      items: 
       required: 
       - firstName 
       properties: 
       firstName: 
        type: string 
       lastName: 
        type: string 
       email: 
        type: string 
       comment: 
        type: string 
    post: 
     summary: Adds a comment to the guestbook 
     description: Adds a comment to the guestbook 
     parameters: 
     - name: firstname 
      in: formData 
      required: true 
      type: string 
     - name: lastname 
      in: formData 
      required: true 
      type: string 
     - name: email 
      in: formData 
      required: true 
      type: string 
     - name: comment 
      in: formData 
      required: true 
      type: string 

     responses: 
     201: 
      description: Shows a successful post 
     '405': 
      description: Invalid input 
    /guestbook/{id}: 
    get: 
     summary: Gets a single post 
     description: Returns a single post 
     operationId: getPost 
     parameters: 
     - name: id 
      in: path 
      description: ID of pet to fetch 
      required: true 
      type: integer 
      format: int64 
     responses: 
     200: 
      description: A list of posts 
      schema: 
      type: array 
      items: 
       required: 
       - firstName 
       properties: 
       id: 
        type: number 
       firstName: 
        type: string 
       lastName: 
        type: string 
       email: 
        type: string 
       comment: 
        type: string 
    delete: 
     summary: Removes a post 
     description: Removes a post 
     operationId: deletePost 
     parameters: 
     - name: id 
      in: path 
     responses: 
     200: 
      description: Post has been removed 

答えて

1

あなたはちょうどあなたがget /guestbook/{id}に行ったようdelete /guestbook/{id} operationidパラメータを記述する必要があります。

/guestbook/{id}: 
    parameters: 
    - name: id 
     in: path 
     description: ID of pet to fetch 
     required: true 
     type: integer 
     format: int64 
    get: 
    summary: Gets a single post 
    description: Returns a single post 
    operationId: getPost 
    responses: 
     200: 
     description: A list of posts 
     schema: 
      type: array 
      items: 
      required: 
       - firstName 
      properties: 
       id: 
       type: number 
       firstName: 
       type: string 
       lastName: 
       type: string 
       email: 
       type: string 
       comment: 
       type: string 
    delete: 
    summary: Removes a post 
    description: Removes a post 
    operationId: deletePost 
    responses: 
     200: 
     description: Post has been removed 

あなたがOpenAPIの(FKA闊歩。)仕様ファイルを作成する方法を学ぶ必要がある場合は、あなたが私のWriting OpenAPI/Swagger Specification Tutorialを読むことができます:あなたはまた、パス/guestbook/{id}のすべての操作のために一度、このパラメータを定義することができます

delete: 
    summary: Removes a post 
    description: Removes a post 
    operationId: deletePost 
    parameters: 
    - name: id 
     in: path 
     description: ID of pet to fetch 
     required: true 
     type: integer 
     format: int64 
    responses: 
    200: 
     description: Post has been removed 

関連する問題