Giter VIP home page Giter VIP logo

user-api's Introduction

User-API (Spring boot example template) CI Docker

Schermata-2022-07-10-alle-13-37-23.png

Example Template: Java Spring, OpenAPI, MongoDB, Docker, Full local dev environment, Helm chart ๐Ÿš€

Quick Start

Using docker-compose

$ docker-compose build
$ docker-compose up -d

Unit Test:

$ mvn test

Services

How to invoke the Rest APIs?

Import the file swagger/openapi.yaml in Postman

Features

  • OpenApi CodeGen integration Spec 3.0
  • Open Metrics Prometheus
  • Docker compose for full local dev environment(Java Spring, Mongo DB, Mongo Express)
  • Java Spring Container Docker with multistage build
  • Example BDD Unit Test
  • Continuous Integration Pipeline (Build Docker Image/Build/Unit Test on new Pull Request) on Github Actions
  • Helm chart, Kubernetes deploy

Example Open API User

swagger/openapi.yaml
openapi: 3.0.0
info:
  version: 1.0.0
  title: User API
  description: Example Java Spring Microservice with OpenAPI and MongoDB

servers:
  - url: http://localhost:8080/

paths:
  /users:
    get:
      description: Returns a list of users
      operationId: findUser
      parameters:
        - name: name
          in: query
          schema:
            type: string
        - name: surname
          in: query
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned a list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'

    post:
      description: Create a new User
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        '201':
          description: Successfully created a new user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '422':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'

  /users/{email}:
    get:
      description: Get User by key (email)
      operationId: getUser
      parameters:
        - name: email
          in: path
          required: true
          schema:
            type: string

      responses:
        '200':
          description: Successfully returned an user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
        '404':
          description: Not found User
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
    put:
      description: Update User
      operationId: updateUser
      parameters:
        - name: email
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'

      responses:
        '200':
          description: Successfully updated an user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
        '404':
          description: Not found User
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
    delete:
      description: Delete User by Key
      operationId: deleteUser
      parameters:
        - name: email
          in: path
          required: true
          schema:
            type: string

      responses:
        '200':
          description: Successfully deleted an user

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
        '404':
          description: Not found User
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'

  /etl/import-csv:
    post:
      description: ETL Import Users by CSV file, example CSV line name#surname#email#address
      operationId: importCSVUsers
      requestBody:
        content:
          application/csv:
            schema:
              type: string
              format: base64
      responses:
        '201':
          description: Successfully imported CSV Users
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserError'
components:
  schemas:
    User:
      type: object
      required:
        - name
        - surname
        - email
        - address
      properties:
        name:
          type: string
          minLength: 1
        surname:
          type: string
          minLength: 1
        email:
          type: string
          format: email
          minLength: 1
        address:
          type: string
          minLength: 1
    UserError:
      type: object
      required:
        - message
      properties:
        message:
          type: string

Documentation

Contributing

Welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.

Happy hacking!

License

This project is licensed under GNU GPL 3 License.

user-api's People

Contributors

mariocandela avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.