简体   繁体   中英

I'm converting json to raml , for /alert it taking get proper response, but for /alert/{alertid}, its not taking response. Here is my raml code

I'm converting json to raml , for /alert/ it to taking get proper response, but for /alert/{alertid} , its not taking response. I want the response for particular alertId API. Here is my raml code. There are many id's in alert I want response for particular id . And for particular id I am hitting an 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

You can try something like this:

#%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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM