All Projects → IBM → Openapi To Graphql

IBM / Openapi To Graphql

Licence: mit
Translate APIs described by OpenAPI Specifications (OAS) into GraphQL

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Openapi To Graphql

Swagger Inflector
Stars: ✭ 131 (-86.54%)
Mutual labels:  rest-api, swagger, openapi-specification
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+190.34%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Codegen
swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
Stars: ✭ 13,859 (+1324.36%)
Mutual labels:  rest-api, swagger, openapi-specification
Eliasdb
EliasDB a graph-based database.
Stars: ✭ 611 (-37.2%)
Mutual labels:  graphql, rest-api, swagger
Swagger Core
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
Stars: ✭ 6,898 (+608.94%)
Mutual labels:  rest-api, swagger, openapi-specification
Springdoc Openapi
Library for OpenAPI 3 with spring-boot
Stars: ✭ 1,113 (+14.39%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Js
Javascript library to connect to swagger-enabled APIs via browser or nodejs
Stars: ✭ 2,319 (+138.34%)
Mutual labels:  rest-api, swagger, openapi-specification
Drf Yasg
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
Stars: ✭ 2,523 (+159.3%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Ui
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
Stars: ✭ 21,279 (+2086.95%)
Mutual labels:  rest-api, swagger, openapi-specification
Drf Spectacular
Sane and flexible OpenAPI 3 schema generation for Django REST framework.
Stars: ✭ 414 (-57.45%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Node
Swagger module for node.js
Stars: ✭ 3,917 (+302.57%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Editor
Swagger Editor
Stars: ✭ 7,365 (+656.94%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Parser
Swagger Spec to Java POJOs
Stars: ✭ 468 (-51.9%)
Mutual labels:  rest-api, swagger, openapi-specification
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (-14.59%)
Mutual labels:  rest-api, swagger, openapi-specification
Swagger Express Middleware
Swagger 2.0 middlware and mocks for Express.js
Stars: ✭ 543 (-44.19%)
Mutual labels:  rest-api, swagger
Rick And Morty Api
The Rick and Morty API
Stars: ✭ 542 (-44.3%)
Mutual labels:  graphql, rest-api
Swagger Parser
Swagger 2.0 and OpenAPI 3.0 parser/validator
Stars: ✭ 710 (-27.03%)
Mutual labels:  rest-api, swagger
Oas Kit
Convert Swagger 2.0 definitions to OpenAPI 3.0 and resolve/validate/lint
Stars: ✭ 516 (-46.97%)
Mutual labels:  swagger, openapi-specification
Clean Ts Api
API em NodeJs usando Typescript, TDD, Clean Architecture, Design Patterns e SOLID principles
Stars: ✭ 619 (-36.38%)
Mutual labels:  graphql, rest-api
Go Gin Api
基于 Gin 进行模块化设计的 API 框架,封装了常用功能,使用简单,致力于进行快速的业务研发。比如,支持 cors 跨域、jwt 签名验证、zap 日志收集、panic 异常捕获、trace 链路追踪、prometheus 监控指标、swagger 文档生成、viper 配置文件解析、gorm 数据库组件、gormgen 代码生成工具、graphql 查询语言、errno 统一定义错误码、gRPC 的使用 等等。
Stars: ✭ 730 (-24.97%)
Mutual labels:  graphql, swagger

GitHub last commit Travis (.org) Join the chat at https://gitter.im/IBM/openapi-to-graphql

OpenAPI-to-GraphQL

Translate APIs described by OpenAPI Specifications (OAS) or Swagger into GraphQL.

Overview of translation

Getting started

OpenAPI-to-GraphQL can be used in two ways:

CLI

The Command Line Interface (CLI) provides a convenient way to start a GraphQL server wrapping an API for a given OpenAPI Specification:

  1. Install the OpenAPI-to-GraphQL CLI using:
    npm i -g openapi-to-graphql-cli
    
  2. Then, run the OpenAPI-to-GraphQL command and point it to an OpenAPI Specification:
    openapi-to-graphql <OAS JSON file path or remote url> [options]
    

For further details, refer to the openapi-to-graphql-cli documentation.

Library

Use OpenAPI-to-GraphQL as a library in your application to generate GraphQL schemas.

  1. Install OpenAPI-to-GraphQL as a dependency:
    npm i -s openapi-to-graphql
    
  2. Require OpenAPI-to-GraphQL and use the createGraphQLSchema function:
    const { createGraphQLSchema } = require("openapi-to-graphql");
    // load or construct OAS (const oas = ...)
    const { schema, report } = await createGraphQLSchema(oas);
    

For further details, refer to the openapi-to-graphql documentation.

Tutorials

Here are some guides to further help you get started:

  • CLI + Loopback tutorial: Learn how to quickly spin up GraphQL wrappers using the OpenAPI-to-GraphQL CLI.
  • Library tutorial: Learn how to use OpenAPI-to-GraphQL as a library, and how to improve the resulting GraphQL wrappers using OAS link definitions.
  • LoopBack tutorial: Learn how to use OpenAPI-to-GraphQL to create GraphQL wrappers for APIs created with LoopBack 4.
  • Subscriptions tutorial: Learn how to create a GraphQL API that supports subscription operations - including how to set up the API server that creates a PubSub instance wrapping a MQTT client.

Characteristics

  • Data-centric The GraphQL interface is created around the data definitions in the given OAS, not around the endpoints, leading to a natural use of GraphQL.

    Example of data-centric design
  • Nested data Links defined in the OAS are used to create nested data structures, allowing for (deeply) nested queries.

    Example of links resolution
  • Automatic query resolution Automatically generated resolvers translate (nested) GraphQL queries to API requests. Request results are translated back to GraphQL responses.

    Example of query resolution
  • Mutations Non-safe, non-idempotent API operations (e.g., POST, PUT, DELETE) are translated to GraphQL mutations. Input payload is type-checked.

    Example of mutation
  • Subscriptions GraphQL subscriptions allow clients to receive a stream of events, such as updates whenever data changes on the GraphQL server. OpenAPI-to-GraphQL can create subscriptions based on callback objects defined in the OAS.

    Example of subscription
  • Authentication OpenAPI-to-GraphQL currently supports authentication via API Key and basic auth. OpenAPI-to-GraphQL wraps secured endpoints into a viewer, which takes the API key / credentials as input.

    Example of authentication
  • API Sanitation Parts of an API that not compatible with GraphQL are automatically sanitized. For example, API parameters and data definition names with unsupported characters (e.g., -, ., ,, :, ;...) are removed. GraphQL queries are desanitized to correctly invoke the REST API and the responses are resanitized to create GraphQL-compliant results.

    Example of sanitation
  • Custom request options Provide headers and query parameters to send with every API request. This allows, for example, to handle authentication or tag requests from GraphQL.

  • Swagger and OpenAPI 3 support OpenAPI-to-GraphQL can handle both Swagger (OpenAPI specification 2.0) as well as OpenAPI specification 3.

Development

OpenAPI-to-GraphQL uses the Lerna monorepo management system. After cloning the entire monorepo repository, you can install Lerna with the command npm install and then install the dependencies for all of the packages with lerna bootstrap.

OpenAPI-to-GraphQL is written in TypeScript. Within each of OpenAPI-to-GraphQL's packages, all source code is contained in the src folder. Use npm run build or npm test to transpile the source files into the final library in the lib folder. Entry-point for the library is index.js in lib.

Research

Our research paper, "Generating GraphQL-Wrappers for REST(-like) APIs", can be found here. The paper describes the challenges of building OpenAPI-to-GraphQL and an experiment in which we evaluated OpenAPI-to-GraphQL against 959 publicly available OAS, provided by APIs.guru, and successfully created GraphQL interfaces for 89.5% of them.

To run the experiment, in the openapi-to-graphql package, load APIs.guru specifications, found here, into the /tmp folder:

npm run guru-load

Then, run tests:

npm run guru-test <number of APIs to test at most>

Similar projects

  • swagger-to-graphql turns a given Swagger (OpenAPI Specification 2.0) into a GraphQL interface, which resolves against the original API. GraphQL schema is based on endpoints, not on data definitions. No links are considered.

  • json-to-graphql turns given JSON objects / arrays into a GraphQL schema. resolve functions need to be provided by the user.

  • StackOverflow discussion points to the above projects.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].