
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
@nldoc/openapi-utils
Advanced tools
A TypeScript utility library for building OpenAPI 3.1.0 specifications programmatically. This library provides a fluent, type-safe API for creating and managing OpenAPI schemas, properties, and references.
This library provides a comprehensive set of utilities for working with OpenAPI specifications including:
The utilities provide a consistent, type-safe way to construct OpenAPI specifications, enabling better API documentation, validation, and integration with OpenAPI-based tools.
Install the package via npm:
npm install @nldoc/openapi-utils
Or using yarn:
yarn add @nldoc/openapi-utils
import {
Property,
Resource,
CollectionProperty,
ComponentSchemaReference
} from '@nldoc/openapi-utils';
// Create a simple property
const nameProperty = new Property('string')
.setTitle('Name')
.setDescription('The name of the resource')
.setMinLength(1)
.setMaxLength(100);
// Create a resource with properties
const userResource = new Resource('User', 'object')
.addProperty('id', new Property('string').setFormat('uuid'), true)
.addProperty('name', nameProperty, true)
.addProperty('email', new Property('string').setFormat('email'), true)
.addExample({
id: '123e4567-e89b-12d3-a456-426614174000',
name: 'John Doe',
email: 'john@example.com'
});
// Create a collection property
const usersCollection = new CollectionProperty(['User'])
.setMinItems(0)
.setDescription('A collection of users');
// Create a schema reference
const userRef = ComponentSchemaReference('User');
Clone the repository:
git clone https://gitlab.com/logius/nldoc/lib/typescript/openapi-utils.git
cd openapi-utils
Install dependencies:
npm install
Build the project:
npm run build
npm run test - Run the test suite with Vitest and coveragenpm run build - Build the TypeScript files for distributionnpm 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 release - Create a semantic releaseThe library provides several key classes and utilities:
The Property class provides a fluent API for building OpenAPI schema properties:
const property = new Property('string')
.setTitle('Example Property')
.setDescription('A description of the property')
.setFormat('email')
.setMinLength(5)
.setMaxLength(100)
.addExample('user@example.com')
.setDefault('default@example.com');
The Resource class extends Property for creating object schemas:
const resource = new Resource('Product', 'object')
.addProperty('id', idProperty, true) // required
.addProperty('name', nameProperty, true)
.addProperty('price', priceProperty, false) // optional
.setProperties({ description: descProperty }, ['description']);
The CollectionProperty class handles array types with discriminators:
const collection = new CollectionProperty(['Product', 'Service'], 'type')
.setMinItems(1)
.addExample([
{ type: 'Product', id: '1', name: 'Widget' },
{ type: 'Service', id: '2', name: 'Support' }
]);
Run the test suite:
npm test
We welcome contributions! Please ensure:
npm test)npm run format:check)npm run lint)This project is licensed under the European Union Public License 1.2 - see LICENSE for details.
FAQs
Utilities for building OpenAPI specifications.
The npm package @nldoc/openapi-utils receives a total of 103 weekly downloads. As such, @nldoc/openapi-utils popularity was classified as not popular.
We found that @nldoc/openapi-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.