All Projects → swaggerql → swaggerql

swaggerql / swaggerql

Licence: MIT license
Easily and simply convert SQL database into a REST API with Swagger documentation

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to swaggerql

ormdb
ORM tool for .Net / .Net.Core
Stars: ✭ 14 (-65%)
Mutual labels:  oracle, mariadb
Tadpolefordbtools
Stars: ✭ 523 (+1207.5%)
Mutual labels:  oracle, mariadb
Sqlprovider
A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
Stars: ✭ 423 (+957.5%)
Mutual labels:  oracle, mariadb
database connections
⚙️Demonstration code to connect R on MacOS to various database flavors.
Stars: ✭ 18 (-55%)
Mutual labels:  oracle, mariadb
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (+322.5%)
Mutual labels:  oracle, mariadb
json-sql-builder2
Level Up Your SQL-Queries
Stars: ✭ 59 (+47.5%)
Mutual labels:  oracle, mariadb
Liquibase
Main Liquibase Source
Stars: ✭ 2,910 (+7175%)
Mutual labels:  oracle, mariadb
MsCoreOne
MsCoreOne is a simple Ecommerce with using many technologies such as .NET 5, Entity Framework Core 5, React 16.13 with modern Clean Architecture, Domain-Driven Design, CQRS, SOLID, Identity Server 4, Blazor. It will focus on resolving the problems always see in the process to develop projects.
Stars: ✭ 77 (+92.5%)
Mutual labels:  swagger-ui, swagger-api
Ebean
Ebean ORM
Stars: ✭ 1,172 (+2830%)
Mutual labels:  oracle, mariadb
Dbshield
Database firewall written in Go
Stars: ✭ 620 (+1450%)
Mutual labels:  oracle, mariadb
dbclient
데이터배이스 관리 / 자동 메일링 / Admin 자동화 / Database IDE Tool. SQL Development Helper. Support DBMS Oracle/Mysql/MS-SQL
Stars: ✭ 35 (-12.5%)
Mutual labels:  oracle, mariadb
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (+340%)
Mutual labels:  oracle, mariadb
laravel-adminer
Adminer database management tool for your Laravel application.
Stars: ✭ 45 (+12.5%)
Mutual labels:  oracle, mariadb
thinkorm
A flexible, lightweight and powerful Object-Relational Mapper for Node.js. Support TypeScript!!
Stars: ✭ 33 (-17.5%)
Mutual labels:  oracle, mariadb
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 (+53097.5%)
Mutual labels:  swagger-ui, swagger-api
Testcontainers Spring Boot
Container auto-configurations for spring-boot based integration tests
Stars: ✭ 460 (+1050%)
Mutual labels:  oracle, mariadb
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+66297.5%)
Mutual labels:  oracle, mariadb
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+5427.5%)
Mutual labels:  oracle, mariadb
Sharding Method
分表分库的新思路——服务层Sharding框架,全SQL、全数据库兼容,ACID特性与原生数据库一致,能实现RR级别读写分离,无SQL解析性能更高
Stars: ✭ 188 (+370%)
Mutual labels:  oracle, mariadb
Ocilib
OCILIB (C and C++ Drivers for Oracle) - Open source C and C++ library for accessing Oracle databases
Stars: ✭ 245 (+512.5%)
Mutual labels:  oracle

SwaggerQL

Build Status CodeQL Docker swaggerql-mysql Docker swaggerql-mariadb Docker swaggerql-postgres Docker swaggerql-oracle Docker swaggerql-sqlite

Swagger + SQL = Simple reference microservice with transparent documentation and no coding.
All you need to do is create a Swagger file and specify SQL queries in the description.

When you should use it:

  • you need an internal microservice with simple queries to an existing database
  • you quickly need a prototype of a reference service
  • you need to test data in the database
  • you need a stub application with database access to test the deployment scripts

Screenshot

Getting Started

Install the appropriate database module before using the SwaggerQL:

  • pg for PostgreSQL and Amazon Redshift
  • mysql2 for MySQL
  • mysql for MariaDB or MySQL
  • sqlite3 for SQLite3
  • mssql for MSSQL
  • oracledb and Oracle instant-client for Oracle
Run SwaggerQL with PostgreSQL
npm install swaggerql
npm install pg

Create config/local.yaml

client: pg
connection:
  host: 127.0.0.1
  user: your_database_user
  password: your_database_password
  database: myapp_test

Run SwaggerQL

$(npm bin)/swaggerql

And try http://0.0.0.0:8000

Run SwaggerQL with Oracle
npm install swaggerql
npm install oracledb

Install Oracle instant-client

Create config/local.yaml

client: oracledb
connection:
  user: your_database_user
  password: your_database_password
  connectString: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=MY_SID)))
pool:
  min: 0
  max: 3

Run SwaggerQL

$(npm bin)/swaggerql

And try http://0.0.0.0:8000

More examples in the repository.

Configuration

Connect to DB

The knex library is used to connect to various databases. The most common configuration file format is:

client: <driver>
connection:
  host: 127.0.0.1
  user: your_database_user
  password: your_database_password
  database: myapp_test

More examples of connection configurations in Knex documentation

See node-config documentation for information about naming, load order and format of configuration files.

REST API

Build APIs by describing them in OpenAPI document specification and importing them via YAML or JSON to construct your own REST API.

The only difference is that a SQL query is inserted into the description field.

paths:
  /two:
    get:
      summary: One plus one equals two
      description: |
        SELECT 1 + 1
      responses:
        200:
          description: OK

The description can use Markdown with a specified SQL query:

description: |
  Add one to one

  ```sql
  SELECT 1 + 1
  ```

Query Parameter Binding

You can pass parameters to SQL query from path, query, form parameters described in Swagger file. Use named bindings, such as :name are interpreted as values and :name: interpreted as identifiers.

paths:
  /increment:
    get:
      summary: Increment of N per one
      description: |
        SELECT 1 + :n
      parameters:
      - name: n
        in: query
        description: Number
        required: true
        style: form
        explode: true
        schema:
          type: integer
      responses:
        200:
          description: OK

Execution options

Query expression can be handled as a transaction if the client sends X-Transaction header. Sometimes there's need to release cursors in the database.

paths:
  /compute:
    get:
      summary: Adding the results of a calculation
      description: |
        insert into table
        select function()
      parameters:
      - name: X-Transaction
        in: header
        description: Run Query in transaction wrapper
        schema:
          type: boolean
          default: true

CLI

Configuration options can be overridden via command-line arguments or environment variables. Priorities are the following:

  • A command-line option has the highest priority. It overrides the environment variable and config file value.
  • An environment variable has second priority. It overrides the config file value.
  • A config file value has the lowest priority.
  • If there isn't a command-line option, environment variable or config file option specified, the default is used.

Run $(npm bin)/swaggerql --help for more information.

Usage: swaggerql [options]

Options:
  -V, --version                output the version number
  -i, --input-spec <path>      path to specification file (default: "openapi.yaml")
  -p, --port <number>          http port to start server (default: 8000)
  -d, --client <name>          name of client SQL driver
  -c, --connection <dsn|json>  connection options to the appropriate database client
  -l, --log-level <level>      logging level: debug, info, warn, error (default: "info")
  -h, --help                   output usage information

Environment variables:

  • SWAGGERQL_INPUT_SPEC — path to specification file
  • SWAGGERQL_PORT — http port to start server
  • SWAGGERQL_CLIENT — name of client SQL driver
  • SWAGGERQL_CONNECTION — connection options to the appropriate database client
  • SWAGGERQL_LOG_LEVEL — logging level

Docker

docker run -it --rm -p 8000:8000 \
        -v $(pwd)/config/local.yaml:/app/config/production.yaml \
        -v $(pwd)/openapi.yaml:/app/openapi.yaml \
        swaggerql/swaggerql-mysql

Available Docker containers:

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].