3d-inventory-oracle-api

This project is an API server for a 3D inventory system connected to an Oracle database, generated using swagger-codegen and based on the OpenAPI Specification. The server relies on commonjs and the oracledb package, with the database running in a Docker container. To start the server, use npm run api-install && npm run nodemon, and the Swagger UI can be accessed at http://localhost:8080/docs. The project uses Swagger OpenAPI 3.0.3 for API generation and documentation. The database setup includes Oracle XE in Docker with customizable options for fast startup and password configuration.

This project is an API server for a 3D inventory system connected to an Oracle database, generated using swagger-codegen and based on the OpenAPI Specification. The server relies on commonjs and the oracledb package, with the database running in a Docker container. To start the server, use npm run api-install && npm run nodemon, and the Swagger UI can be accessed at http://localhost:8080/docs. The project uses Swagger OpenAPI 3.0.3 for API generation and documentation. The database setup includes Oracle XE in Docker with customizable options for fast startup and password configuration.

Overview

API server project for 3d-inventory to Oracle database. It was generated by swagger-codegen. Using OpenAPI-Spec from a remote server, you can easily generate a server shortcut.

  • Simple commonjs (backend) api depends on oracledb
  • Generated by Swagger v3.
  • API is in /src
  • Oracle db in docker (statefull)

Running the server

To run the API server:

npm run api-install && npm run nodemon

To view the Swagger UI interface:

open http://localhost:8080/docs

This project leverages the mega-awesome swagger-tools middle-ware which does most all the work.

Swagger OpenAPI definition 3.0.3

OpenAPI (formerly known as Swagger) is a specification for building and documenting RESTful APIs. It provides a standardized way to describe the structure and behavior of RESTful web services, making it easier for developers to understand, use, and interact with these APIs.

https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject

NPM run

  1. Make backup npm run swagger:backup-before-generate –>
    cp -v ./src/service/* ./backup
  2. Update jars swagger:get-jars
  3. Generate api by docker swagger:v3-docker-generate
  4. Edit openapi by swagger editor: swagger:v3-editor and swagger:v3-editor-open
  5. Generate api by jars swagger:v3-generate

Setup Database

Set password

# call shell
docker exec -it 5c6a4a0c10638e88b0d1a5e35867ed908b78d8dc7fae4df804fc8cbcf1d78921 sh
# change password
docker exec -d 5c6a4a0c1063 ./setPassword.sh babilon5
# run some other command in container like sql scripts
docker exec -ti 5c6a4a0c1063 sh -c "echo a && echo b"
sqlplus sys/babilon5@172.17.0.2:1521/orclpdb1 as sysdba

Use image of DB

This images have more options to configure pass and faststart: https://hub.docker.com/r/gvenzl/oracle-xe

I use db-oracle-21-faststart simple as this:

docker run -d -p 1521:1521 -e ORACLE_PASSWORD=babilon5 -v oracle-volume:/opt/oracle/oradata gvenzl/oracle-xe:21.3.0-faststart

Oracle

Shell

sqlplus sys/LetsTest1@localhost/XE as sysdb

Podman

podman exec -ti oracle-xe sqlplus sys/LetsTest1@localhost/XE as sysdb

Create test database and test user

CREATE PLUGGABLE DATABASE test ADMIN USER test IDENTIFIED BY LetsTest1 FILE_NAME_CONVERT=('pdbseed','test');
ALTER PLUGGABLE DATABASE test OPEN;
ALTER PLUGGABLE DATABASE test SAVE STATE;
ALTER SESSION SET CONTAINER=test;
GRANT CONNECT, RESOURCE, CREATE VIEW, UNLIMITED TABLESPACE TO test;
exit;
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments