zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    swagger & api

    swagger ui

    
    # run server
    $ swagger project start api-app
    
    # call api
    $ curl http://127.0.0.1:8080/hello?name=xgqfrms
    # { "message": "Hello, xgqfrms!" }
    # http://localhost:8080/users
    
    
    
    # install CLI
    $ npm i -g swagger
    
    # create a new swagger project
    $ swagger project create api-app
    
    # editor API
    $ swagger project edit api-app
    
    
    # run server
    $ swagger project start api-app
    
    
    # call api
    $ curl http://127.0.0.1:8080/hello?name=xgqfrms
    # { "message": "Hello, xgqfrms!" }
    
    

    controller

    
    function hello(req, res) {
        var name = req.swagger.params.name.value || 'stranger';
        var hello = util.format('Hello, %s!', name);
        res.json({"message": hello});
    }
    
    
        paths:
            /hello:
                x-swagger-router-controller: hello_world
    

    ./api/controllers

    ./api/controllers/hello_world.js

    
    {
        "name": "swagger_api_test",
        "author": {
            "name": "xgqfrms"
        },
        "version": "1.0.0",
        "description": "swagger_api_test",
        "license": "MIT",
        "scripts": {
            "app": "npm run server"
        }
    }
    
    


    error

    bug

    
    Error initializing middleware
    Error: Swagger document(s) failed validation so the server cannot start
    
    

    https://github.com/swagger-api/swagger-node/issues/354


    solution

    solution

    
    $ cd ./api/swagger && swagger validate swagger.yaml
    
    

    image


    - & yaml bug

    missing - symbol bug

    image


    bug & solution

    Error: Response validation failed: failed schema validation

    https://github.com/xgqfrms/swagger-api/issues/5#issuecomment-430860246


  • 相关阅读:
    第八次作业
    第七次作业2
    jsp第十一次作业
    jsp第十次作业
    jsp第九次作业
    jsp第八次作业
    jsp第七次作业
    jsp第六次作业
    软件测试第二次作业
    jsp第五次作业
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/9808520.html
Copyright © 2011-2022 走看看