mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
Continue api-reference docs
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const swaggerAutogen = require('swagger-autogen')({ openapi: '3.0.0' });
|
||||
const fs = require('fs').promises;
|
||||
const yaml = require('js-yaml');
|
||||
const { secretSchema } = require('./schemas/index.ts');
|
||||
|
||||
/**
|
||||
* Generates OpenAPI specs for all Infisical API endpoints:
|
||||
* - spec.json in /backend for api-serving
|
||||
* - spec.yaml in /docs for API reference
|
||||
*/
|
||||
const generateOpenAPISpec = async () => {
|
||||
const doc = {
|
||||
info: {
|
||||
title: 'Infisical API',
|
||||
description: 'List of all available APIs that can be consumed',
|
||||
},
|
||||
host: ['https://infisical.com'],
|
||||
servers: [
|
||||
{
|
||||
url: 'https://infisical.com',
|
||||
description: 'Production server'
|
||||
},
|
||||
{
|
||||
url: 'http://localhost:8080',
|
||||
description: 'Local server'
|
||||
}
|
||||
],
|
||||
securityDefinitions: {
|
||||
bearerAuth: {
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
bearerFormat: 'JWT',
|
||||
description: "This security definition uses the HTTP 'bearer' scheme, which allows the client to authenticate using a JSON Web Token (JWT) that is passed in the Authorization header of the request."
|
||||
},
|
||||
apiKeyAuth: {
|
||||
type: 'apiKey',
|
||||
in: 'header',
|
||||
name: 'X-API-Key',
|
||||
description: 'This security definition uses an API key, which is passed in the header of the request as the value of the "X-API-Key" header. The client must provide a valid key in order to access the API.'
|
||||
}
|
||||
},
|
||||
definitions: {
|
||||
CurrentUser: {
|
||||
_id: '',
|
||||
email: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
publicKey: '',
|
||||
encryptedPrivateKey: '',
|
||||
updatedAt: '',
|
||||
createdAt: ''
|
||||
},
|
||||
ProjectKey: {
|
||||
encryptedkey: '',
|
||||
nonce: '',
|
||||
sender: {
|
||||
publicKey: ''
|
||||
},
|
||||
receiver: '',
|
||||
workspace: ''
|
||||
},
|
||||
CreateSecret: {
|
||||
type: 'shared',
|
||||
secretKeyCiphertext: '',
|
||||
secretKeyIV: '',
|
||||
secretKeyTag: '',
|
||||
secretValueCiphertext: '',
|
||||
secretValueIV: '',
|
||||
secretValueTag: '',
|
||||
secretCommentCiphertext: '',
|
||||
secretCommentIV: '',
|
||||
secretCommentTag: ''
|
||||
},
|
||||
UpdateSecret: {
|
||||
id: '',
|
||||
secretKeyCiphertext: '',
|
||||
secretKeyIV: '',
|
||||
secretKeyTag: '',
|
||||
secretValueCiphertext: '',
|
||||
secretValueIV: '',
|
||||
secretValueTag: '',
|
||||
secretCommentCiphertext: '',
|
||||
secretCommentIV: '',
|
||||
secretCommentTag: ''
|
||||
},
|
||||
Secret: {
|
||||
_id: '',
|
||||
version: 1,
|
||||
workspace : '',
|
||||
type: 'shared',
|
||||
user: null,
|
||||
secretKeyCiphertext: '',
|
||||
secretKeyIV: '',
|
||||
secretKeyTag: '',
|
||||
secretValueCiphertext: '',
|
||||
secretValueIV: '',
|
||||
secretValueTag: '',
|
||||
secretCommentCiphertext: '',
|
||||
secretCommentIV: '',
|
||||
secretCommentTag: '',
|
||||
updatedAt: '',
|
||||
createdAt: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const outputJSONFile = '../spec.json';
|
||||
const outputYAMLFile = '../docs/spec.yaml';
|
||||
const endpointsFiles = ['../src/app.ts'];
|
||||
|
||||
const spec = await swaggerAutogen(outputJSONFile, endpointsFiles, doc);
|
||||
await fs.writeFile(outputYAMLFile, yaml.dump(spec.data));
|
||||
}
|
||||
|
||||
generateOpenAPISpec();
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const secretSchema = require('./secretSchema.ts');
|
||||
|
||||
module.exports = {
|
||||
secretSchema
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
const secretSchema = {
|
||||
_id: {
|
||||
type: 'string',
|
||||
format: 'objectId'
|
||||
},
|
||||
version: {
|
||||
type: 'number'
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = secretSchema;
|
||||
Reference in New Issue
Block a user