@nldoc/api-specification
v1.1.187
Published
Specification for NLdoc API
Readme
NLdoc API Specification
An OpenAPI 3.1.0 compatible specification for the NLdoc API. This TypeScript library provides a comprehensive API framework for document conversion services, health monitoring, and file management.
Overview
This specification defines a standardized REST API for NLdoc services including:
- Document conversion operations
- Server-Sent Events (SSE) for conversion progress tracking
- File retrieval and management
- Health check endpoints
The API follows RPC-style principles inspired by REST, using clear, action-driven endpoints and standard HTTP semantics to deliver streamlined operations.
Getting Started
Prerequisites
- Node.js >= 22.0.0 < 23.0.0
- npm >= 10.0.0 < 12.0.0
Installation
Install the package via npm:
npm install @nldoc/api-specificationOr using yarn:
yarn add @nldoc/api-specificationBasic Usage
import {
specification,
validExamples,
invalidExamples
} from '@nldoc/api-specification';
// Access the OpenAPI specification
console.log(specification);
// Use valid examples for testing
console.log(validExamples);
// Use invalid examples for validation testing
console.log(invalidExamples);Accessing the OpenAPI Specification
After building the project, the complete OpenAPI 3.1.0 specification is available at:
# Build the project first
npm run build
# The OpenAPI specification is now available at:
# - public/openapi.json (JSON format)
# - public/index.html (Interactive HTML documentation)Development
Local Setup
Clone the repository:
git clone https://gitlab.com/logius/nldoc/spec/api.git cd api-specificationInstall dependencies:
npm installBuild the project:
npm run build
Available Scripts
npm run test- Run the test suite with Vitest and generate coverage reportsnpm run build- Build the OpenAPI specification, examples, and TypeScript filesnpm run lint- Lint the codebase using ESLintnpm run format- Format code using Prettiernpm run format:check- Check code formattingnpm run fix- Auto-fix linting and formatting issuesnpm run lint:openapi- Validate OpenAPI specification against ADR standards and generate reportsnpm run lint:spectral- Validate against Dutch API Design Rules (ADR 2.1)npm run lint:vacuum- Generate an HTML report for the OpenAPI specification
Building Components
The build process consists of several steps:
- OpenAPI Generation:
npm run build:openapi- Generates the OpenAPI JSON specification - Example Extraction:
npm run build:examples- Extracts valid and invalid test examples - TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
- Documentation:
npm run build:redocly- Generates HTML documentation using Redocly
API Endpoints
The specification defines the following main endpoints:
Core Operations
- POST /conversion: Convert files to different formats
- GET /conversion/{uuid}: Stream conversion events via Server-Sent Events (SSE)
- GET /file/{key}: Retrieve converted files
- HEAD /file/{key}: Check file metadata
Health Monitoring
- GET /health: Get health status with detailed response
- HEAD /health: Quick health check
Headers and Parameters
The API uses standard headers for request tracking and versioning:
X-Trace-Id: Distributed tracing identifierX-Request-Id: Unique request identifierAPI-Version: API version informationContent-Type: Content type for requests and responses
API Documentation
The generated OpenAPI specification can be viewed:
- Locally: After building, open
public/index.htmlin your browser - Online: View the latest release documentation
Testing
Run the test suite:
npm testContributing
We welcome contributions! Please ensure:
- All tests pass (
npm test) - Code is properly formatted (
npm run format:check) - Linting rules are followed (
npm run lint) - OpenAPI specification is valid (
npm run lint:openapi) - Compliance with Dutch API Design Rules (
npm run lint:spectral)
License
This project is licensed under the European Union Public License 1.2 - see LICENSE for details.
Acknowledgements
- Built on OpenAPI 3.1.0 specification
- Follows Dutch API Design Rules (ADR) version 2.1
- Uses Redocly for API documentation generation
- Validated with @quobix/vacuum and Spectral
