2017-09-17 3 views
0

Je suis en train de convertir json en raml, pour/alert/il faut prendre une réponse correcte, mais pour /alert/{alertid}, il ne prend pas de réponse. Je veux la réponse pour une API alertId particulière. Voici mon code raml. Il y a beaucoup d'id en alerte Je veux une réponse pour un identifiant particulier. Et pour un identifiant particulier, je tape sur une API.Je suis en train de convertir json en raml, pour/alerter en prenant la bonne réponse, mais pour/alert/{alertid}, il ne prend pas de réponse. Voici mon code raml

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

ce que vous entendez par là ne lève pas la réponse? En outre, vous ne pouvez pas déclarer les types deux fois, supprimez la deuxième déclaration. Et pourquoi utilisez-vous un json include dans le type au lieu d'utiliser le type RAML que vous avez spécifié? – Pedro

Répondre

0

Vous pouvez essayer quelque chose comme ceci:

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