Initial project setup: Add contracts, API definitions, tests, and documentation
- Add Foundry project configuration (foundry.toml, foundry.lock) - Add Solidity contracts (TokenFactory138, BridgeVault138, ComplianceRegistry, etc.) - Add API definitions (OpenAPI, GraphQL, gRPC, AsyncAPI) - Add comprehensive test suite (unit, integration, fuzz, invariants) - Add API services (REST, GraphQL, orchestrator, packet service) - Add documentation (ISO20022 mapping, runbooks, adapter guides) - Add development tools (RBC tool, Swagger UI, mock server) - Update OpenZeppelin submodules to v5.0.0
This commit is contained in:
87
api/tools/swagger-ui/src/generate-standalone.ts
Normal file
87
api/tools/swagger-ui/src/generate-standalone.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Generate standalone HTML documentation
|
||||
* Creates a self-contained HTML file with embedded OpenAPI spec
|
||||
*/
|
||||
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import YAML from 'yamljs';
|
||||
|
||||
const openapiPath = join(__dirname, '../../packages/openapi/v1/openapi.yaml');
|
||||
const openapiSpec = YAML.load(openapiPath);
|
||||
const outputPath = join(__dirname, '../swagger-ui/static/standalone.html');
|
||||
|
||||
const htmlTemplate = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>eMoney Token Factory API Documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5.10.3/swagger-ui.css" />
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
*, *:before, *:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
.swagger-ui .topbar {
|
||||
display: none;
|
||||
}
|
||||
.swagger-ui .info {
|
||||
margin: 50px 0;
|
||||
}
|
||||
.swagger-ui .info .title {
|
||||
font-size: 36px;
|
||||
color: #3b4151;
|
||||
}
|
||||
.swagger-ui .info .description {
|
||||
font-size: 16px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.10.3/swagger-ui-bundle.js"></script>
|
||||
<script src="https://unpkg.com/swagger-ui-dist@5.10.3/swagger-ui-standalone-preset.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
const spec = ${JSON.stringify(openapiSpec, null, 2)};
|
||||
|
||||
const ui = SwaggerUIBundle({
|
||||
spec: spec,
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout",
|
||||
persistAuthorization: true,
|
||||
displayRequestDuration: true,
|
||||
filter: true,
|
||||
tryItOutEnabled: true,
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'patch', 'delete'],
|
||||
docExpansion: 'list',
|
||||
defaultModelsExpandDepth: 2,
|
||||
defaultModelExpandDepth: 2,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
writeFileSync(outputPath, htmlTemplate);
|
||||
console.log(`Standalone HTML documentation generated: ${outputPath}`);
|
||||
|
||||
85
api/tools/swagger-ui/src/index.ts
Normal file
85
api/tools/swagger-ui/src/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Swagger UI Server
|
||||
* Serves interactive API documentation from OpenAPI specification
|
||||
*/
|
||||
|
||||
import express from 'express';
|
||||
import swaggerUi from 'swagger-ui-express';
|
||||
import YAML from 'yamljs';
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import path from 'path';
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.SWAGGER_PORT || 8080;
|
||||
|
||||
// Load OpenAPI specification
|
||||
const openapiPath = join(__dirname, '../../packages/openapi/v1/openapi.yaml');
|
||||
const openapiSpec = YAML.load(openapiPath);
|
||||
|
||||
// Serve static files (OAuth2 redirect, standalone HTML)
|
||||
app.use('/static', express.static(join(__dirname, '../../swagger-ui/static')));
|
||||
|
||||
// Swagger UI options
|
||||
const swaggerOptions = {
|
||||
customCss: `
|
||||
.swagger-ui .topbar { display: none; }
|
||||
.swagger-ui .info { margin: 50px 0; }
|
||||
.swagger-ui .info .title { font-size: 36px; }
|
||||
.swagger-ui .info .description { font-size: 16px; line-height: 1.6; }
|
||||
.swagger-ui .scheme-container { margin: 20px 0; }
|
||||
`,
|
||||
customSiteTitle: 'eMoney Token Factory API Documentation',
|
||||
customfavIcon: '/favicon.ico',
|
||||
swaggerOptions: {
|
||||
persistAuthorization: true,
|
||||
displayRequestDuration: true,
|
||||
filter: true,
|
||||
tryItOutEnabled: true,
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'patch', 'delete'],
|
||||
docExpansion: 'list',
|
||||
defaultModelsExpandDepth: 2,
|
||||
defaultModelExpandDepth: 2,
|
||||
oauth2RedirectUrl: '/static/oauth2-redirect.html',
|
||||
},
|
||||
};
|
||||
|
||||
// Serve Swagger UI
|
||||
app.use('/api-docs', swaggerUi.serve);
|
||||
app.get('/api-docs', swaggerUi.setup(openapiSpec, swaggerOptions));
|
||||
|
||||
// Serve OpenAPI spec as JSON
|
||||
app.get('/openapi.json', (req, res) => {
|
||||
res.json(openapiSpec);
|
||||
});
|
||||
|
||||
// Serve OpenAPI spec as YAML
|
||||
app.get('/openapi.yaml', (req, res) => {
|
||||
res.setHeader('Content-Type', 'text/yaml');
|
||||
res.send(readFileSync(openapiPath, 'utf-8'));
|
||||
});
|
||||
|
||||
// Serve standalone HTML
|
||||
app.get('/standalone', (req, res) => {
|
||||
res.sendFile(join(__dirname, '../../swagger-ui/static/standalone.html'));
|
||||
});
|
||||
|
||||
// Redirect root to docs
|
||||
app.get('/', (req, res) => {
|
||||
res.redirect('/api-docs');
|
||||
});
|
||||
|
||||
// Health check
|
||||
app.get('/health', (req, res) => {
|
||||
res.json({ status: 'ok', service: 'swagger-ui' });
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Swagger UI server running on http://localhost:${PORT}`);
|
||||
console.log(`API Documentation: http://localhost:${PORT}/api-docs`);
|
||||
console.log(`OpenAPI JSON: http://localhost:${PORT}/openapi.json`);
|
||||
console.log(`OpenAPI YAML: http://localhost:${PORT}/openapi.yaml`);
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user