LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Specification

First, let’s build an OpenAPI 3.0 specification with several endpoints to demo database access. You will need swagger editor to create a specification. Once the specification is created, you can export it into both YAML and JSON format. YAML is easy for designers to work in an editor and is easy to be consumed by the light-codegen and light-rest-4j framework.

Here is the OpenAPI 3.0 specification created and it can be found in model-config

openapi: 3.0.0
info:
  version: 1.0.0
  title: light-rest-4j Database Tutorial
  description: A demo on how to connect, query and update Oracle/Mysql/Postgres.
  contact:
    email: [email protected]
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
paths:
  /query:
    get:
      description: Single query to database table
      operationId: getQuery
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RandomNumber"
              examples:
                response:
                  value:
                    id: 123
                    randomNumber: 456
      security:
        - database_auth:
            - database.r
  /queries:
    get:
      description: Multiple queries to database table
      operationId: getQueries
      parameters:
        - name: queries
          in: query
          description: Number of random numbers
          required: false
          schema:
            type: integer
            format: int32
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/RandomNumber"
              examples:
                response:
                  value:
                    - id: 123
                      randomNumber: 456
                    - id: 567
                      randomNumber: 789
      security:
        - database_auth:
            - database.r
  /updates:
    get:
      description: Multiple updates to database table
      operationId: getUpdates
      parameters:
        - name: queries
          in: query
          description: Number of random numbers
          required: false
          schema:
            type: integer
            format: int32
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/RandomNumber"
              examples:
                response:
                  value:
                    - id: 123
                      randomNumber: 456
                    - id: 567
                      randomNumber: 789
      security:
        - database_auth:
            - database.w
servers:
  - url: http://database.networknt.com/v1
  - url: https://database.networknt.com/v1
components:
  securitySchemes:
    database_auth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: http://localhost:8888/oauth2/code
          scopes:
            database.w: write database table
            database.r: read database table
  schemas:
    RandomNumber:
      type: object
      required:
        - id
        - randomNumber
      properties:
        id:
          type: integer
          format: int32
          description: a unique id as primary key
        randomNumber:
          type: integer
          format: int32
          description: a random number

Now let’s clone the model-config repo to your working directory so that we can use the OpenAPI specification as well as the config.json to generate a service project.

cd ~/networknt
git clone https://github.com/networknt/model-config.git

In the next step, we are going to generate and build a new project.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Specification” was last updated: June 1, 2019: fixes #103 migrate the database tutorial from Swagger 2.0 to OpenAPI 3.0 (#104) (8ebbc59)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute