Я конвертирую json в raml, так как / alert он получает правильный ответ, но для / alert / {alerttid} он не принимает ответ. Вот мой код raml

Я конвертирую json в raml, чтобы / alert / он получал правильный ответ, но для /alert/{alertid} он не принимает ответ. Мне нужен ответ для конкретного API-интерфейса alertId. Вот мой код raml. Есть много идентификаторов в предупреждении, я хочу получить ответ для определенного идентификатора. И для конкретного идентификатора я нажимаю 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

person Anurag Doshi    schedule 17.09.2017    source источник
comment
что вы имеете в виду, говоря, что он не отвечает? Также нельзя объявлять типы дважды, удалите второе объявление. И почему вы используете json include в типе вместо того, чтобы использовать тип RAML, который вы указали?   -  person Pedro    schedule 18.09.2017


Ответы (1)


Вы можете попробовать что-то вроде этого:

#%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
person Rafael Manzoni    schedule 18.09.2017