Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger node #4

Open
xgqfrms opened this issue May 11, 2018 · 8 comments
Open

swagger node #4

xgqfrms opened this issue May 11, 2018 · 8 comments
Labels

Comments

@xgqfrms
Copy link
Owner

xgqfrms commented May 11, 2018

swagger node

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

https://app.swaggerhub.com/apis/xgqfrms/test/1.0.0#/

image

@xgqfrms
Copy link
Owner Author

xgqfrms commented May 11, 2018

translate

https://github.com/gildata/swagger-node

image

Tutorial

# install CLI
$ npm i -g swagger

# create a new swagger project
$ swagger project create hello-world

# editor API
$ swagger project edit hello-world


# run server
$ swagger project start hello-world


# call api
$ curl http://127.0.0.1:10010/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"
    }
}

@xgqfrms
Copy link
Owner Author

xgqfrms commented May 11, 2018

image

new swagger

# 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:10010/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"
    }
}

@xgqfrms
Copy link
Owner Author

xgqfrms commented May 11, 2018

image

typo bug

swagger-api/swagger-node#562

image

# 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:10010/hello?name=xgqfrms
# { "message": "Hello, xgqfrms!" }

@xgqfrms
Copy link
Owner Author

xgqfrms commented May 11, 2018

how to disable after submit form default refresh page ?

如何禁用 提交 form 后刷新

https://stackoverflow.com/questions/7803814/prevent-refresh-of-page-when-button-inside-form-clicked

https://stackoverflow.com/questions/4194207/prevent-user-from-seeing-previously-visited-secured-page-after-logout

<!DOCTYPE html>
<html lang="zh-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>POST & upload file</title>
</head>

<body>
    <section>
        <form action='http://127.0.0.1:8080/users?key={"name":"abc"}' method='POST' enctype="multipart/form-data">
            <!-- <form action='http://127.0.0.1:8080/users?{"name":"abc"}' method='POST' enctype="multipart/form-data"> -->
            <!-- <form action='http://127.0.0.1:8080/users?name=abc' method='POST' enctype="multipart/form-data"> -->
            <input type='file' name='uploadfile' />
            <input type="name" value="xgqfrms" />
            <input type="submit" value="提交" onclick="notSubmit()" />
        </form>
        <button type="submit">提交</button>
    </section>
    <!-- js -->
    <script>
        const notSubmit = () => {
            return false;
        };
    </script>
</body>

</html>

image

image


https://imququ.com/post/four-ways-to-post-data-in-http.html

http://www.cnblogs.com/fish-li/archive/2011/07/17/2108884.html#_label3

http://www.jb51.net/web/447549.html
http://www.jb51.net/article/98618.htm

Repository owner locked and limited conversation to collaborators May 12, 2018
@xgqfrms xgqfrms added swagger node swagger node swagger api swagger api help wanted and removed swagger api swagger api swagger node swagger node labels May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant