-var express = require('express');
-var path = require('path');
-var cookieParser = require('cookie-parser');
-var logger = require('morgan');
+const createError = require('http-errors');
+const express = require('express');
+const compression = require( 'express-compression' );
+const bodyParser = require( 'body-parser' );
+const cookieParser = require('cookie-parser');
+const log4js = require( './src/middleware/loggerMiddleWare' );
+const passport = require( 'passport' );
+let hookJWTStrategy = require( './src/middleware/passport' );
+const cors = require( 'cors' );
+const port = normalizePort( process.env.PORT || '3601' );
+const runOnce = require ( './src/middleware/custom-startup' );
+const Routes = require( './src/routes' );
+const phsdb = require( './src/phsdb' );
+const { Client } = require('ssh2');
+const fs = require('fs');
-var indexRouter = require('./routes/index');
-var usersRouter = require('./routes/users');
+const buffer = require('buffer');
+global.Blob = buffer.Blob
-var app = express();
+const app = express();
+const http = require( 'http' ).createServer( app );
-app.use(logger('dev'));
-app.use(express.json());
-app.use(express.urlencoded({ extended: false }));
+app.set('etag', false)
+
+app.use((req, res, next) => {
+ res.set('Cache-Control', 'no-store');
+ next()
+});
+
+global.phsdb = phsdb;
+
+// noinspection JSCheckFunctionSignatures
+app.use( bodyParser.json( {
+ limit:'50mb', extended:true
+} ) );
+app.use( bodyParser.urlencoded( {
+ extended:true,
+ limit: '50mb'
+} ) );
app.use(cookieParser());
-app.use(express.static(path.join(__dirname, 'public')));
-app.use('/', indexRouter);
-app.use('/users', usersRouter);
+//Setting up log4js
+const logger = log4js.default;
+
+// Set log level based on the active environment for global logger
+logger.level = 'warn';
+
+switch (process.env.PHS_ENV) {
+ case 'DEV':
+ logger.level = 'debug';
+ break;
+ case 'UNIT_TEST':
+ logger.level = 'info';
+ break;
+ default:
+ break;
+}
+global.logger = logger;
+
+// For automatic logging of all requests
+app.use( log4js.express );
+
+logger.info('PHS_ENV: ' + process.env.PHS_ENV );
+logger.info('NODE_ENV: ' + process.env.NODE_ENV );
+logger.info('Testing log levels: info, debug and error. Only shows for PHS_ENV=DEV' );
+logger.info('Test log level: info' ); // Should show in all NODE_ENV settings
+logger.debug('Test log level: debug' ); // Should not show in PRODUCTION
+
+//Initialize passport
+app.use( passport.initialize() );
+hookJWTStrategy( passport );
+
+//Run custom startup code once
+runOnce().catch( err => logger.error( err ) );
+
+//Set express body parsing options.
+app.use( compression() );
+app.use( express.json() );
+app.use( express.urlencoded( { extended:false } ) );
+app.use(cookieParser());
+
+// 2FA Cors:
+app.use(cors({
+ exposedHeaders: ['LastFetchDateTime', 'Authentication'],
+ origin: [
+ // Home
+ 'http://localhost:30005', // local dev
+ 'http://localhost:23601',
+ 'http://phs-home:3000', // import / export jobs
+ 'https://phs-home.phasecustomsoft.com',
+ 'https://phs-admin.phasecustomsoft.com',
+ 'https://www.phasecustomsoft.com',
+ // Customer (local dev)
+ 'http://localhost:30006', // local dev
+ 'http://rt2-customer:3000', // import / export jobs
+ 'https://customer-f.roto-versal.com',
+ 'https://customer-t.roto-versal.com',
+ 'https://customer-demo.roto-versal.com',
+ 'https://customer.roto-versal.com',
+ // Admin (local dev)
+ 'http://localhost:8100',
+ 'http://localhost:30007',
+ 'https://admin-t.roto-versal.com',
+ 'https://admin-f.roto-versal.com',
+ 'https://admin-demo.roto-versal.com',
+ 'https://admin.roto-versal.com',
+ // App (local dev)
+ 'http://localhost:8101',
+ 'https://app-t.roto-versal.com',
+ 'https://app-f.roto-versal.com',
+ 'https://app-demo.roto-versal.com',
+ 'https://app.roto-versal.com',
+ // Public website
+ 'https://www-t.roto-versal.com',
+ 'https://www.roto-versal.com'
+ ],
+ credentials: true,
+ methods: ['GET', 'POST', 'PUT', 'DELETE'],
+ allowedHeaders: ['Content-Type', 'Authorization', 'Origin', 'X-Requested-With', 'Accept', 'Access-Control-Allow-Origin', 'Cookie', 'phs-app-version'],
+ optionsSuccessResponds: true,
+}));
+
+//Send the current server date/time for each request
+app.use( function ( req, res, next ) {
+ res.setHeader( 'LastFetchDateTime', new Date().toLocaleString() );
+ next();
+} );
+
+app.use( '/', Routes.APIRoutes( passport ) );
+app.set( 'port', port );
+//Create HTTP Server for App
+// noinspection JSCheckFunctionSignatures
+http.listen( port );
+http.on( 'error', onError );
+http.on( 'listening', onListening );
+
+
+process.on('uncaughtException', function(err) {
+ logger.error( '*************uncaughtException******' );
+ logger.error( err );
+});
+
+process.on('unhandledRejection', (err) => {
+ logger.error( '*************unhandledRejection******' );
+ logger.error(err.name, err.message);
+});
+
+
+// catch 404 and forward to the error handler
+app.use( function ( req, res, next ) {
+ if (req.url === '/.well-known/appspecific/com.chrome.devtools.json' ) next();
+ else {
+ logger.debug(req.originalUrl)
+ logger.debug(req.headers['x-forwarded-for'])
+ next( createError( 404 ) );
+ }
+
+} );
+
+function normalizePort( val ) {
+ const port = parseInt( val, 10 );
+
+ if (isNaN( port )) {
+ // named pipe
+ return val;
+ }
+
+ if (port >= 0) {
+ // port number
+ return port;
+ }
+
+ return false;
+}
+
+/**
+ * Event listener for HTTP server "error" event.
+ */
+
+function onError( error ) {
+ if (error.syscall !== 'listen') {
+ throw error;
+ }
+
+ const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
+
+ // handle specific listen errors with friendly messages
+ switch (error.code) {
+ case 'EACCES':
+ logger.error( bind + ' requires elevated privileges' );
+ process.exit( 1 );
+ break;
+ case 'EADDRINUSE':
+ logger.error( bind + ' is already in use' );
+ process.exit( 1 );
+ break;
+ default:
+ throw error;
+ }
+}
+
+/**
+ * Event listener for HTTP server "listening" event.
+ */
+
+function onListening() {
+ const addr = http.address();
+ const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
+ logger.info( 'Listening on ' + bind );
+}
+
+// error handler
+const errorHandler = ( err, req, res, next ) => {
+ logger.error( '*************errorHandler******' );
+ if (err) {
+ logger.error( err );
+ // set locals, only providing error in DEVELOPMENT
+ res.locals.message = err.message;
+ res.locals.error = req.app.get( 'env' ) === 'DEVELOPMENT' ? err : {};
+ // render the error page
+ res.status( err.status || 500 );
+ res.send(err);
+ } else next()
+};
+
+app.use( errorHandler );
+
+console.log('running on ' + port);
module.exports = app;
--- /dev/null
+{
+ "swagger": "2.0",
+ "info": {
+ "description": "API for managing units, inspection checks, and related entities",
+ "version": "1.0.0",
+ "title": "CES API",
+ "contact": {
+ "email": "abc@gmail.com"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "schemes": ["https", "http"],
+ "host": "api-phasecustomsoft.com",
+ "basePath": "/",
+ "securityDefinitions": {
+ "Bearer": {
+ "type": "apiKey",
+ "name": "Authorization",
+ "in": "header"
+ }
+ },
+ "security": [{"Bearer": []}],
+ "paths": {
+ "/base_inspection_check/": {
+ "post": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Create a new base inspection check",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Base inspection check object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/base_inspection_check/{inspection_check_id}": {
+ "get": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Get base inspection check by ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "ID of base inspection check to return",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Base inspection check not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Delete base inspection check",
+ "description": "",
+ "parameters": [
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "ID of base inspection check to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Base inspection check not found"
+ }
+ }
+ }
+ },
+ "/base_inspection_check/dot": {
+ "get": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Get DOT-related base inspection checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/base_inspection_check/static": {
+ "get": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Get static base inspection checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/base_inspection_check/{inspection_check_id}/photo-requirements": {
+ "put": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Update photo requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "ID of base inspection check to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Photo requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "photo": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Base inspection check not found"
+ }
+ }
+ }
+ },
+ "/base_inspection_check/{inspection_check_id}/details-requirements": {
+ "put": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Update details requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "ID of base inspection check to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Details requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Base inspection check not found"
+ }
+ }
+ }
+ },
+ "/base_inspection_check/{inspection_check_id}/sort-order": {
+ "put": {
+ "tags": ["Base Inspection Check"],
+ "summary": "Update sort order",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "ID of base inspection check to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Sort order object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "sort_order": {
+ "type": "number",
+ "format": "double"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/BaseInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Base inspection check not found"
+ }
+ }
+ }
+ },
+ "/user/": {
+ "post": {
+ "tags": ["User"],
+ "summary": "Create a new user",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "User object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/user/by-employee-number/{employee_number}": {
+ "get": {
+ "tags": ["User"],
+ "summary": "Get user by employee number",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "employee_number",
+ "in": "path",
+ "description": "Employee number of user to return",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ },
+ "400": {
+ "description": "Invalid employee number supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ }
+ },
+ "/user/active": {
+ "get": {
+ "tags": ["User"],
+ "summary": "Get active users",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/user/{id}/deactivate": {
+ "put": {
+ "tags": ["User"],
+ "summary": "Deactivate user",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of user to deactivate",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Deactivation details",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "deactivatedById": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ }
+ },
+ "/user/{id}/reactivate": {
+ "put": {
+ "tags": ["User"],
+ "summary": "Reactivate user",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of user to reactivate",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ }
+ },
+ "/user/{id}": {
+ "put": {
+ "tags": ["User"],
+ "summary": "Update user",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of user to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "User object to update",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": ["User"],
+ "summary": "Delete user",
+ "description": "",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of user to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ }
+ },
+ "/unit_category/": {
+ "post": {
+ "tags": ["Unit Category"],
+ "summary": "Create a new unit category",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Unit category object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/UnitCategory"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/UnitCategory"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ },
+ "get": {
+ "tags": ["Unit Category"],
+ "summary": "Get all unit categories",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitCategory"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_category/by-name/{name}": {
+ "get": {
+ "tags": ["Unit Category"],
+ "summary": "Get unit category by name",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "name",
+ "in": "path",
+ "description": "Name of unit category to return",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitCategory"
+ }
+ },
+ "400": {
+ "description": "Invalid name supplied"
+ },
+ "404": {
+ "description": "Unit category not found"
+ }
+ }
+ }
+ },
+ "/unit_category/name-exists/{name}": {
+ "get": {
+ "tags": ["Unit Category"],
+ "summary": "Check if unit category name exists",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "name",
+ "in": "path",
+ "description": "Name to check",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "exists": {
+ "type": "boolean"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_category/{id}/name": {
+ "put": {
+ "tags": ["Unit Category"],
+ "summary": "Update unit category name",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of unit category to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "New name object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitCategory"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit category not found"
+ }
+ }
+ }
+ },
+ "/unit_category/{id}": {
+ "delete": {
+ "tags": ["Unit Category"],
+ "summary": "Delete unit category",
+ "description": "",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of unit category to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Unit category not found"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/": {
+ "post": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Create a new unit type inspection check",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Unit type inspection check object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/{unit_type_id}/{inspection_check_id}": {
+ "get": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Get unit type inspection check by IDs",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_type_id",
+ "in": "path",
+ "description": "Unit type ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid IDs supplied"
+ },
+ "404": {
+ "description": "Unit type inspection check not found"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/by-unit-type/{unit_type_id}": {
+ "get": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Get checks by unit type",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_type_id",
+ "in": "path",
+ "description": "Unit type ID",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid unit_type_id supplied"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/dot": {
+ "get": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Get DOT-related checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/static": {
+ "get": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Get static checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/{unit_type_id}/{inspection_check_id}/photo-requirements": {
+ "put": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Update photo requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_type_id",
+ "in": "path",
+ "description": "Unit type ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Photo requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "photo": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit type inspection check not found"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/{unit_type_id}/{inspection_check_id}/details-requirements": {
+ "put": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Update details requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_type_id",
+ "in": "path",
+ "description": "Unit type ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Details requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit type inspection check not found"
+ }
+ }
+ }
+ },
+ "/unit_type_inspection_check/{unit_type_id}/{inspection_check_id}/sort-order": {
+ "put": {
+ "tags": ["Unit Type Inspection Check"],
+ "summary": "Update sort order",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_type_id",
+ "in": "path",
+ "description": "Unit type ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Sort order object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "sort_order": {
+ "type": "number",
+ "format": "double"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitTypeInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit type inspection check not found"
+ }
+ }
+ }
+ },
+ "/api_key/": {
+ "post": {
+ "tags": ["API Key"],
+ "summary": "Create a new API key",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "API key object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/ApiKey"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/ApiKey"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/api_key/{id}": {
+ "get": {
+ "tags": ["API Key"],
+ "summary": "Get API key by ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of API key to return",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/ApiKey"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "API key not found"
+ }
+ }
+ },
+ "put": {
+ "tags": ["API Key"],
+ "summary": "Update API key",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of API key to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "API key object to update",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/ApiKey"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/ApiKey"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "API key not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": ["API Key"],
+ "summary": "Delete API key",
+ "description": "",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of API key to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "API key not found"
+ }
+ }
+ }
+ },
+ "/api_key/by-key/{apiKey}": {
+ "get": {
+ "tags": ["API Key"],
+ "summary": "Get API key by value",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "apiKey",
+ "in": "path",
+ "description": "API key value to return",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/ApiKey"
+ }
+ },
+ "400": {
+ "description": "Invalid API key supplied"
+ },
+ "404": {
+ "description": "API key not found"
+ }
+ }
+ }
+ },
+ "/unit/": {
+ "get": {
+ "tags": ["Unit"],
+ "summary": "Get all units",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Unit"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ },
+ "post": {
+ "tags": ["Unit"],
+ "summary": "Create a new unit",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Unit object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/Unit"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/Unit"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit/by-unit-type/{unit_type_id}": {
+ "get": {
+ "tags": ["Unit"],
+ "summary": "Get units by unit type ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_type_id",
+ "in": "path",
+ "description": "Unit type ID",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Unit"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid unit_type_id supplied"
+ }
+ }
+ }
+ },
+ "/unit/by-unit-category/{unit_category_id}": {
+ "get": {
+ "tags": ["Unit"],
+ "summary": "Get units by unit category ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_category_id",
+ "in": "path",
+ "description": "Unit category ID",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Unit"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid unit_category_id supplied"
+ }
+ }
+ }
+ },
+ "/unit/inspections/": {
+ "get": {
+ "tags": ["Unit"],
+ "summary": "Get inspections by lookup code",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "query",
+ "description": "Lookup code",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/": {
+ "post": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Create a new unit category inspection check",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Unit category inspection check object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/{unit_category_id}/{inspection_check_id}": {
+ "get": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Get unit category inspection check by IDs",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_category_id",
+ "in": "path",
+ "description": "Unit category ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid IDs supplied"
+ },
+ "404": {
+ "description": "Unit category inspection check not found"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/by-unit-category/{unit_category_id}": {
+ "get": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Get checks by unit category",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_category_id",
+ "in": "path",
+ "description": "Unit category ID",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid unit_category_id supplied"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/dot": {
+ "get": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Get DOT-related checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/static": {
+ "get": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Get static checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/{unit_category_id}/{inspection_check_id}/photo-requirements": {
+ "put": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Update photo requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_category_id",
+ "in": "path",
+ "description": "Unit category ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Photo requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "photo": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit category inspection check not found"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/{unit_category_id}/{inspection_check_id}/details-requirements": {
+ "put": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Update details requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_category_id",
+ "in": "path",
+ "description": "Unit category ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Details requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit category inspection check not found"
+ }
+ }
+ }
+ },
+ "/unit_category_inspection_check/{unit_category_id}/{inspection_check_id}/sort-order": {
+ "put": {
+ "tags": ["Unit Category Inspection Check"],
+ "summary": "Update sort order",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_category_id",
+ "in": "path",
+ "description": "Unit category ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "name": "inspection_check_id",
+ "in": "path",
+ "description": "Inspection check ID",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Sort order object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "sort_order": {
+ "type": "number",
+ "format": "double"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/UnitCategoryInspection"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Unit category inspection check not found"
+ }
+ }
+ }
+ },
+ "/inspection_check/": {
+ "post": {
+ "tags": ["Inspection Check"],
+ "summary": "Create a new inspection check",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Inspection check object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ },
+ "get": {
+ "tags": ["Inspection Check"],
+ "summary": "Get all inspection checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/inspection_check/by-name/{name}": {
+ "get": {
+ "tags": ["Inspection Check"],
+ "summary": "Get inspection check by name",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "name",
+ "in": "path",
+ "description": "Name of inspection check to return",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ },
+ "400": {
+ "description": "Invalid name supplied"
+ },
+ "404": {
+ "description": "Inspection check not found"
+ }
+ }
+ }
+ },
+ "/inspection_check/dot": {
+ "get": {
+ "tags": ["Inspection Check"],
+ "summary": "Get DOT-related inspection checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/inspection_check/static": {
+ "get": {
+ "tags": ["Inspection Check"],
+ "summary": "Get static inspection checks",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/inspection_check/{id}/photo-requirements": {
+ "put": {
+ "tags": ["Inspection Check"],
+ "summary": "Update photo requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of inspection check to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Photo requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "photo": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Inspection check not found"
+ }
+ }
+ }
+ },
+ "/inspection_check/{id}/details-requirements": {
+ "put": {
+ "tags": ["Inspection Check"],
+ "summary": "Update details requirements",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of inspection check to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Details requirements object",
+ "required": true,
+ "schema": {
+ "type": "object",
+ "properties": {
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/InspectionCheck"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Inspection check not found"
+ }
+ }
+ }
+ },
+ "/inspection_check/{id}": {
+ "delete": {
+ "tags": ["Inspection Check"],
+ "summary": "Delete inspection check",
+ "description": "",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of inspection check to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Inspection check not found"
+ }
+ }
+ }
+ },
+ "/form/": {
+ "post": {
+ "tags": ["Form"],
+ "summary": "Create a new form",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Form object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/Form"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/Form"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ },
+ "get": {
+ "tags": ["Form"],
+ "summary": "Get all forms",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Form"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/form/{id}": {
+ "get": {
+ "tags": ["Form"],
+ "summary": "Get form by ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of form to return",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/Form"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Form not found"
+ }
+ }
+ },
+ "put": {
+ "tags": ["Form"],
+ "summary": "Update form",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of form to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Form object to update",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/Form"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/Form"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Form not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": ["Form"],
+ "summary": "Delete form",
+ "description": "",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of form to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Form not found"
+ }
+ }
+ }
+ },
+ "/form/by-unit/{unit_id}": {
+ "get": {
+ "tags": ["Form"],
+ "summary": "Get forms by unit ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "unit_id",
+ "in": "path",
+ "description": "Unit ID to filter forms",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Form"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid unit_id supplied"
+ }
+ }
+ }
+ },
+ "/form/by-user/{user_id}": {
+ "get": {
+ "tags": ["Form"],
+ "summary": "Get forms by user ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "user_id",
+ "in": "path",
+ "description": "User ID to filter forms",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Form"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid user_id supplied"
+ }
+ }
+ }
+ },
+ "/form_attachment/": {
+ "post": {
+ "tags": ["Form Attachment"],
+ "summary": "Create a new form attachment",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Form attachment object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "Created",
+ "schema": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ },
+ "get": {
+ "tags": ["Form Attachment"],
+ "summary": "Get all form attachments",
+ "description": "",
+ "produces": ["application/json"],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ }
+ }
+ }
+ },
+ "/form_attachment/{id}": {
+ "get": {
+ "tags": ["Form Attachment"],
+ "summary": "Get form attachment by ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of form attachment to return",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Form attachment not found"
+ }
+ }
+ },
+ "put": {
+ "tags": ["Form Attachment"],
+ "summary": "Update form attachment",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of form attachment to update",
+ "required": true,
+ "type": "integer"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Form attachment object to update",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ },
+ "400": {
+ "description": "Invalid input"
+ },
+ "404": {
+ "description": "Form attachment not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": ["Form Attachment"],
+ "summary": "Delete form attachment",
+ "description": "",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "description": "ID of form attachment to delete",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Deleted"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Form attachment not found"
+ }
+ }
+ }
+ },
+ "/form_attachment/by-form/{form_id}": {
+ "get": {
+ "tags": ["Form Attachment"],
+ "summary": "Get form attachments by form ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "form_id",
+ "in": "path",
+ "description": "Form ID to filter attachments",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid form_id supplied"
+ }
+ }
+ }
+ },
+ "/form_attachment/by-creator/{created_by_id}": {
+ "get": {
+ "tags": ["Form Attachment"],
+ "summary": "Get form attachments by creator ID",
+ "description": "",
+ "produces": ["application/json"],
+ "parameters": [
+ {
+ "name": "created_by_id",
+ "in": "path",
+ "description": "User ID who created the attachments",
+ "required": true,
+ "type": "integer"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/FormAttachment"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid created_by_id supplied"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "BaseInspection": {
+ "type": "object",
+ "properties": {
+ "inspection_check_id": {
+ "type": "integer"
+ },
+ "sort_order": {
+ "type": "number",
+ "format": "double"
+ },
+ "dot": {
+ "type": "boolean"
+ },
+ "photo": {
+ "type": "boolean"
+ },
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ },
+ "is_static": {
+ "type": "boolean"
+ }
+ }
+ },
+ "User": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ },
+ "employee_number": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ },
+ "is_active": {
+ "type": "boolean"
+ },
+ "deactivated_at": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "deactivated_by_id": {
+ "type": "integer"
+ }
+ }
+ },
+ "UnitCategory": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "UnitTypeInspection": {
+ "type": "object",
+ "properties": {
+ "unit_type_id": {
+ "type": "integer"
+ },
+ "inspection_check_id": {
+ "type": "integer"
+ },
+ "sort_order": {
+ "type": "number",
+ "format": "double"
+ },
+ "dot": {
+ "type": "boolean"
+ },
+ "photo": {
+ "type": "boolean"
+ },
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ },
+ "is_static": {
+ "type": "boolean"
+ }
+ }
+ },
+ "Unit": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "lookup_code": {
+ "type": "string"
+ },
+ "unit_id": {
+ "type": "string"
+ },
+ "unit_category_id": {
+ "type": "integer"
+ },
+ "unit_type_id": {
+ "type": "integer"
+ }
+ }
+ },
+ "UnitCategoryInspection": {
+ "type": "object",
+ "properties": {
+ "unit_category_id": {
+ "type": "integer"
+ },
+ "inspection_check_id": {
+ "type": "integer"
+ },
+ "sort_order": {
+ "type": "number",
+ "format": "double"
+ },
+ "dot": {
+ "type": "boolean"
+ },
+ "photo": {
+ "type": "boolean"
+ },
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ },
+ "is_static": {
+ "type": "boolean"
+ }
+ }
+ },
+ "ApiKey": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "api_key": {
+ "type": "string"
+ },
+ "user_id": {
+ "type": "integer"
+ }
+ }
+ },
+ "InspectionCheck": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ },
+ "dot": {
+ "type": "boolean"
+ },
+ "photo": {
+ "type": "boolean"
+ },
+ "details": {
+ "type": "boolean"
+ },
+ "details_required": {
+ "type": "boolean"
+ },
+ "photo_required": {
+ "type": "boolean"
+ },
+ "photo_only": {
+ "type": "boolean"
+ },
+ "photo_count": {
+ "type": "integer"
+ },
+ "is_static": {
+ "type": "boolean"
+ }
+ }
+ },
+ "UnitType": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ },
+ "unit_category_id": {
+ "type": "integer"
+ }
+ }
+ },
+ "Form": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "unit_id": {
+ "type": "integer"
+ },
+ "user_id": {
+ "type": "integer"
+ },
+ "form_data": {
+ "type": "object"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ },
+ "FormAttachment": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "form_id": {
+ "type": "integer"
+ },
+ "file_data": {
+ "type": "string",
+ "format": "byte"
+ },
+ "file_type": {
+ "type": "string"
+ },
+ "created_by_id": {
+ "type": "integer"
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file