我正在将json转换为raml,用于/警告它获取正确的响应,但对于/ alert / {alertid},它没有采取响应。这是我的raml代码

时间:2017-09-17 17:38:04

标签: javascript jquery json swagger raml

我正在将json转换为raml,/ alert /它将获得正确的响应,但对于/alert/{alertid},它没有采取响应。我想要特定alertId API的响应。这是我的raml代码。警报中有很多id我想要特定id的响应。对于特定的id,我正在使用API​​。

#%RAML 1.0
title: Test the load customer REST Services
version: 1.0
protocols: [ HTTPS ] 
baseUri: http://myapi.mysite.com/api/
mediaType: application/json
securitySchemes:
  basicAuth:
    description: Each request must contain the header
    type: Basic Authentication
    describedBy:
      headers:
        Authorization:
          description: Used to send
          type: string
      responses:
        401:
          description: |
            Provided username and password is invalid.
types: 
  alert:
    type: object
    properties: 
          id:  string
          description: string
          assetId:  string
          alertId: string
          code: integer
          ownerId?: string
          metadata: 
            type: object
            properties: 
                indicatorId: string

types:
  837a-dcf2a7d556c5:
    type: object
    properties: 
          id:  string
          description: string
          assetId:  string
          alertId: string
          code: integer
          ownerId?: string
          metadata: 
            type: object
            properties: 
                indicatorId: string
/alert:
    get:
        description: Get list of alert API.
        headers: 
        body: 
        responses: 
          200:
            body:
                type: !include alert.json
    /{alertId}:
            get:
                description: Get list of by Id.
                headers: 
                body: 
                responses: 
                    200:
                        body: 
                            type: !include 837a-dcf2a7d556c5.json

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

#%RAML 1.0
title: Test the load customer REST Services
version: 1.0
protocols: [ HTTPS ] 
baseUri: http://myapi.mysite.com/api/
mediaType: application/json
securitySchemes:
  basicAuth:
    description: Each request must contain the header
    type: Basic Authentication
    describedBy:
      headers:
        Authorization:
          description: Used to send
          type: string
      responses:
        401:
          description: |
            Provided username and password is invalid.
types: 
  alert:
    type: object
    properties: 
          id:  string
          description: string
          assetId:  string
          alertId: string
          code: integer
          ownerId?: string
          metadata: 
            type: object
            properties: 
                indicatorId: string

  837a-dcf2a7d556c5:
    type: object
    properties: 
          id:  string
          description: string
          assetId:  string
          alertId: string
          code: integer
          ownerId?: string
          metadata: 
            type: object
            properties: 
                indicatorId: string
/alert:
    get:
        description: Get list of alert API.
        headers: 
        body: 
        responses: 
          200:
            body:
                application/json:
                    type: alert
    /{alertId}:
            get:
                description: Get list of by Id.
                headers: 
                body: 
                responses: 
                    200:
                        body:
                            application/json:
                                type: 837a-dcf2a7d556c5