美文网首页
Learn MuleSoft from beginner to

Learn MuleSoft from beginner to

作者: ElliotG | 来源:发表于2023-04-25 14:42 被阅读0次

    1. What is API Specification

    An API Specification provides an understanding of how an API behaves.

    • What kind of request it accepts
    • What kind of response it returns
    • What are mandatory fields/data types, etc.

     

    2. Design Center of Anypoint Platform

    Design Center helps us to create API Specification in RAML(RESTful API Modeling Language).

    It supports RAML by versions 0.8 and 1.

    Core Elements:

    • Resource
      It is the unique name we give to identify a resource

    • Method
      GET, POST, PUT, DELETE, PATCH etc.

    • Request
      Body, queryparams, uriparams, headers, etc.

    • Http Status
      200, 201, 400, 404, 500, etc.

     

    3. Design API

    image.png
    • 3-2) Create new API specification
    image.png image.png image.png

    RAML Code:

    #%RAML 1.0
    title: session-2
    
    /search:
      get:
        queryParameters:
          keyword:
            type: string
            minLength: 3
            maxLength: 10
        responses:
          200:
            body:
              application/json:
                example:
                  {"message" : "result returned successful"}
    

    • 3-3) Mock API
    image.png image.png
    • 3-4) Make your API Spec public
    image.png

    Note: the copied public URL is the root, you should combined with your relative URL.
    (eg: http://xxxx/xxx + /search?keyword=abc, http://xxxx/xxx is root URL you copied, /search?keyword=abc is your relative request URL)

    相关文章

      网友评论

          本文标题:Learn MuleSoft from beginner to

          本文链接:https://www.haomeiwen.com/subject/hpxmjdtx.html