Giter VIP home page Giter VIP logo

openapi's Introduction


Wechaty Puppet OpenAPI Specification (OAS)

Wechaty REST API Server with OpenAPI Specification (Swagger)

Table of Contents
  1. About
  2. Motivation
  3. Screenshots
  4. Features
  5. Install
  6. Usage
  7. Architecture
  8. Resources
  9. Contributing
  10. Author
  11. Copyright & License

About

OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including:

  • Available endpoints (/users) and operations on each endpoint (GET /users, POST /users)
  • Operation parameters Input and output for each operation
  • Authentication methods
  • Contact information, license, terms of use, and other information.

API specifications can be written in YAML or JSON. The format is easy to learn and readable to both humans and machines. The complete OpenAPI Specification can be found on GitHub: OpenAPI 3.0 Specification

NOTE:

This repo is working in the process. We hope we can finish an alpha version in April, and be ready to Beta in May!

Issues & PRs are welcome, thank you very much for your attention.

Motivation

We have OpenAPI for Wechaty Puppet, and we want a RESTful API as well, so we built OpenAPI Specification (OAS, former Swagger) on top of gRPC, with the power of gRPC OAS Gateway.

Screenshots


View Wechaty OpenAPI Specification on SwaggerHub

Features

  1. A Standalone HTTP Server wechaty-openapi-server
  2. An Express Router for easy mounting to any existing Express HTTP Server.

Install

npm install wechaty-openapi

Usage

1. Standalone Server

export WECHATY_PUPPET_SERVICE_TOKEN=__YOUR_TOKEN__
wechaty-openapi-server \
  --mountpoint /api
  --port 8080

Then visit http://localhost:8080/api

2. Express Router

TBW

Architecture

Thanks to the ecosystem of gRPC, we can generate OpenAPI Specification from our gRPC proto definitions automatically.

We are using gRPC to JSON proxy generator following the gRPC HTTP spec as the OpenAPI Specification generator (protoc-gen-openapiv2), and using Like grpc-gateway, but written in node and dynamic project to serve an HTTP RESTful API to gRPC proxy.

Image credit: gRPC Gateway

Learn more about the RESTful API service for Wechaty from Wechaty OpenAPI.

See also: AIP-4222 - Routing headers

Resources

Read blogs with the openapi tag at https://wechaty.js.org/tags.html#openapi.

Check out RESOURCES.md file for learning resources.

Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for more details.

Releases

Since its creation in 2016, a number of Wechaty versions have been released. For more information about the release history and the current stable version, you can read the Wechaty release notes on Github.

Maintainer

Wechaty is maintained by Huan, Rui, and a community of Open Source Contributors. We are always looking for people to join the Wechaty community to maintain the Wechaty codebase and documentation. You necessarily don't have to be a programmer to contribute to Wechaty. To get started contributing, you can read the CONTRIBUTING.md.

Getting help

Wechaty has a community of very helpful contributors on different platforms you can join to get help from. Before joining any of the communities, we recommend that you read our Code of conduct]o that you adhere to our community guidelines. A full list of the different Wechaty communities can be accessed from the Wechaty community section of this documentation.

Copyright & License

Wechaty is an Open Source Project. It is released under Apache-2.0 license and the corresponding documentation is released under the Creative Commons license.

openapi's People

Contributors

dependabot[bot] avatar huan avatar iamrajiv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

openapi's Issues

npm install wechaty-openapi 提示[email protected]版本被废弃

🐛 Bug Report

(A clear and concise description of what the bug is.)

npm WARN deprecated [email protected]: This library will not receive further updates other than security fixes. We recommend using @grpc/grpc-js instead.
(##################) ⠋ reify:grpc: WARN deprecated [email protected]: This library will not receive further updates other than security fixes. We recommend usi

nodejs版本:16.16.0
系统:mac, centos都存在该问题

Enable Event Streaming for RESTful API

How to start wechaty-openapi-server?

📚 Documentation

npm install wechaty-openapi

error
image

Run command ./node_modules/.bin/wechaty-openapi-server
image

How to start wechaty-openapi-server?Is it possible to improve the documentation?

(A clear and concise description of what the issue is.)

How to specify a default value for parameters in gRPC google.api.http

What I want to do is:

  rpc DirtyPayload (puppet.DirtyPayloadRequest) returns (puppet.DirtyPayloadResponse) {
    option (google.api.http) = {
      additional_bindings {
        put: "/message/{id}/dirty"
        default_value: type=PAYLOAD_TYPE_MESSAGE
      }
      additional_bindings {
        put: "/contacts/{id}/dirty
        default_value: type=PAYLOAD_TYPE_CONTACT
      }
  }

The default_value: type=PAYLOAD_TYPE_MESSAGE is what I want to do, but it seems there's not an easy way to do that.

I'm trying to use

put: "/message/{id}/dirty{type=PAYLOAD_TYPE_MESSAGE}"
put: "/contacts/{id}/dirty/{type=PAYLOAD_TYPE_CONTACT}"

now, but it seems to have other problems...

Related Issues

A puppet used to encapsulate OpenAPI.

Is your feature request related to a problem? Please describe.

Recently, I learned wechaty openapi, which is a very exciting feature. When I saw it, I was thinking about how to use it.

As a serious SDK dependency, I suggest that we encapsulate the API call method into a puppet, such as puppet-http or puppet-api, so that we can fully use Wechaty instances in another stateless service to call all the above APIs instead of a separate SDK.

Like this, when I want to call the API request GET /contacts, I will use const contactList = await bot.Contact.findAll() .

npm install failed

Env:

  • Mac
  • Cmd - npm install wechaty-openapi
  • npm version - 7.6.1

Fail to Install npm install wechaty-openapi
Error log:

5784 verbose stack Error: 404 Not Found - GET https://cdn.npm.taobao.org/wechaty-openapi/-/wechaty-openapi-0.1.0.tgz
5784 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:123:15
5784 verbose stack     at runMicrotasks (<anonymous>)
5784 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
5785 verbose statusCode 404
5786 verbose pkgid wechaty-openapi@https://registry.npm.taobao.org/wechaty-openapi/-/wechaty-openapi-0.1.0.tgz
5787 verbose cwd /Users/ives/code/work_foxconn/fimo-wechaty-noc
5788 verbose Darwin 20.3.0
5789 verbose argv "/usr/local/Cellar/node/14.11.0/bin/node" "/usr/local/bin/npm" "install" "wechaty-openapi"
5790 verbose node v14.11.0
5791 verbose npm  v7.6.1
5792 error code E404
5793 error 404 Not Found - GET https://cdn.npm.taobao.org/wechaty-openapi/-/wechaty-openapi-0.1.0.tgz
5794 error 404
5795 error 404 'wechaty-openapi@https://registry.npm.taobao.org/wechaty-openapi/-/wechaty-openapi-0.1.0.tgz' is not in the npm registry.
5796 error 404 You should bug the author to publish it (or use the name yourself!)
5797 error 404 Note that you can also install from a
5798 error 404 tarball, folder, http url, or git url.
5799 verbose exit 1```

Open API Plugin Support

openAPI.use(pluginFactory())

for easy adding new RESTful API endpoints to the Wechaty OpenAPI system.

Do we have more detailed instruction for usage?

🐛 Bug Report

I tried to follow the instruction but looks like I unable to run it on my device
image

I have tried to run this repo directly, but the same error occurred, so did I miss some steps or this tool doesn't work anymore?

Upload file via auto-generated OpenAPI specification with gRPC backend

It seems that the support for the file upload with gRPC & OpenAPI generator is not very well.

  1. The google.api.http has no annotation for file uploading...
  2. The gRPC client streaming for file uploading is complicated...

Need to find a way to make it work because we need to send FileBox to our server...

Related Links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.