Serverless : Add an example to a requestModel










0















I've an AWS serverless API definition written in YAML with the help of the serverless-documentation plugin.



It's articulated like this :



  1. serverless.yml :

startCreatingItem:
handler: index.startCreatingItem
description: Request a new item
events:
- http:
path: items
method: post
cors: true
private: true
reqValidatorName: 'xMyRequestValidator'
documentation: $file(./documentation/items/startCreatingItem.yml)



  1. startCreatingItem.yml :

summary: "Request a new item"
description: "Item information creation"
tags:
-Items
requestBody:
description: Item to be generated
requestModels:
"application/json": "ItemInfo"
methodResponses:
-
statusCode: "200"
description: "Item creation added"
responseModels:
"application/json": "ItemInfo"



  1. ItemInfo.json :


"type": "object",
"description": "Model representing the item information",
"required": [ "results" ],
"properties":
"id":
"type": "string",
"format": "uuid",
"description": "The item identifier"
,
"results":
"type": "array",
"description": "A list of result identifier to include in the item",
"items":
"type": "string",
"format": "uuid"

,



I'd like to add a request model example for the object ItemInfo, so it appears in the Swagger page (where the dev can try some things directly from within this page).
For example, I was thinking of something like this in the serverless.yml file :



startCreatingItem:
handler: index.startCreatingItem
description: Request a new item
events:
- http:
path: items
method: post
cors: true
private: true
reqValidatorName: 'xMyRequestValidator'
documentation: $file(./documentation/items/startCreatingItem.yml)
example :
results: [
006897b5-e3fc-4358-8c27-cd54dfd53d49,
769e1c03-9136-465b-93ad-90d889245557
]

(but that doesn't seem to work obviously).



If you have any question or remark, I'll be glad to answer you :)
Thank you in advance for your help !










share|improve this question


























    0















    I've an AWS serverless API definition written in YAML with the help of the serverless-documentation plugin.



    It's articulated like this :



    1. serverless.yml :

    startCreatingItem:
    handler: index.startCreatingItem
    description: Request a new item
    events:
    - http:
    path: items
    method: post
    cors: true
    private: true
    reqValidatorName: 'xMyRequestValidator'
    documentation: $file(./documentation/items/startCreatingItem.yml)



    1. startCreatingItem.yml :

    summary: "Request a new item"
    description: "Item information creation"
    tags:
    -Items
    requestBody:
    description: Item to be generated
    requestModels:
    "application/json": "ItemInfo"
    methodResponses:
    -
    statusCode: "200"
    description: "Item creation added"
    responseModels:
    "application/json": "ItemInfo"



    1. ItemInfo.json :


    "type": "object",
    "description": "Model representing the item information",
    "required": [ "results" ],
    "properties":
    "id":
    "type": "string",
    "format": "uuid",
    "description": "The item identifier"
    ,
    "results":
    "type": "array",
    "description": "A list of result identifier to include in the item",
    "items":
    "type": "string",
    "format": "uuid"

    ,



    I'd like to add a request model example for the object ItemInfo, so it appears in the Swagger page (where the dev can try some things directly from within this page).
    For example, I was thinking of something like this in the serverless.yml file :



    startCreatingItem:
    handler: index.startCreatingItem
    description: Request a new item
    events:
    - http:
    path: items
    method: post
    cors: true
    private: true
    reqValidatorName: 'xMyRequestValidator'
    documentation: $file(./documentation/items/startCreatingItem.yml)
    example :
    results: [
    006897b5-e3fc-4358-8c27-cd54dfd53d49,
    769e1c03-9136-465b-93ad-90d889245557
    ]

    (but that doesn't seem to work obviously).



    If you have any question or remark, I'll be glad to answer you :)
    Thank you in advance for your help !










    share|improve this question
























      0












      0








      0








      I've an AWS serverless API definition written in YAML with the help of the serverless-documentation plugin.



      It's articulated like this :



      1. serverless.yml :

      startCreatingItem:
      handler: index.startCreatingItem
      description: Request a new item
      events:
      - http:
      path: items
      method: post
      cors: true
      private: true
      reqValidatorName: 'xMyRequestValidator'
      documentation: $file(./documentation/items/startCreatingItem.yml)



      1. startCreatingItem.yml :

      summary: "Request a new item"
      description: "Item information creation"
      tags:
      -Items
      requestBody:
      description: Item to be generated
      requestModels:
      "application/json": "ItemInfo"
      methodResponses:
      -
      statusCode: "200"
      description: "Item creation added"
      responseModels:
      "application/json": "ItemInfo"



      1. ItemInfo.json :


      "type": "object",
      "description": "Model representing the item information",
      "required": [ "results" ],
      "properties":
      "id":
      "type": "string",
      "format": "uuid",
      "description": "The item identifier"
      ,
      "results":
      "type": "array",
      "description": "A list of result identifier to include in the item",
      "items":
      "type": "string",
      "format": "uuid"

      ,



      I'd like to add a request model example for the object ItemInfo, so it appears in the Swagger page (where the dev can try some things directly from within this page).
      For example, I was thinking of something like this in the serverless.yml file :



      startCreatingItem:
      handler: index.startCreatingItem
      description: Request a new item
      events:
      - http:
      path: items
      method: post
      cors: true
      private: true
      reqValidatorName: 'xMyRequestValidator'
      documentation: $file(./documentation/items/startCreatingItem.yml)
      example :
      results: [
      006897b5-e3fc-4358-8c27-cd54dfd53d49,
      769e1c03-9136-465b-93ad-90d889245557
      ]

      (but that doesn't seem to work obviously).



      If you have any question or remark, I'll be glad to answer you :)
      Thank you in advance for your help !










      share|improve this question














      I've an AWS serverless API definition written in YAML with the help of the serverless-documentation plugin.



      It's articulated like this :



      1. serverless.yml :

      startCreatingItem:
      handler: index.startCreatingItem
      description: Request a new item
      events:
      - http:
      path: items
      method: post
      cors: true
      private: true
      reqValidatorName: 'xMyRequestValidator'
      documentation: $file(./documentation/items/startCreatingItem.yml)



      1. startCreatingItem.yml :

      summary: "Request a new item"
      description: "Item information creation"
      tags:
      -Items
      requestBody:
      description: Item to be generated
      requestModels:
      "application/json": "ItemInfo"
      methodResponses:
      -
      statusCode: "200"
      description: "Item creation added"
      responseModels:
      "application/json": "ItemInfo"



      1. ItemInfo.json :


      "type": "object",
      "description": "Model representing the item information",
      "required": [ "results" ],
      "properties":
      "id":
      "type": "string",
      "format": "uuid",
      "description": "The item identifier"
      ,
      "results":
      "type": "array",
      "description": "A list of result identifier to include in the item",
      "items":
      "type": "string",
      "format": "uuid"

      ,



      I'd like to add a request model example for the object ItemInfo, so it appears in the Swagger page (where the dev can try some things directly from within this page).
      For example, I was thinking of something like this in the serverless.yml file :



      startCreatingItem:
      handler: index.startCreatingItem
      description: Request a new item
      events:
      - http:
      path: items
      method: post
      cors: true
      private: true
      reqValidatorName: 'xMyRequestValidator'
      documentation: $file(./documentation/items/startCreatingItem.yml)
      example :
      results: [
      006897b5-e3fc-4358-8c27-cd54dfd53d49,
      769e1c03-9136-465b-93ad-90d889245557
      ]

      (but that doesn't seem to work obviously).



      If you have any question or remark, I'll be glad to answer you :)
      Thank you in advance for your help !







      rest aws-lambda yaml serverless aws-serverless






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 15:12









      InvvardInvvard

      5671615




      5671615






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303322%2fserverless-add-an-example-to-a-requestmodel%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303322%2fserverless-add-an-example-to-a-requestmodel%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo