Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## 0.4.0 (2026-08-10)

### Features

* **oas**: support OAS 3.1 and 3.2 in getConfiguration (OAS31/OAS32 configurations)
* **amf**: bump amf-client-js from 5.10.2 to 5.11.12531 (exposes OAS31/OAS32, AMF team fixes)

## 0.3.0 (2026-04-07)

### Features
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ function getConfiguration(type) {
case 'OAS 3.0':
case 'OAS 3':
return OASConfiguration.OAS30();
case 'OAS 3.1':
return OASConfiguration.OAS31();
case 'OAS 3.2':
return OASConfiguration.OAS32();
case 'ASYNC 2.0': return AsyncAPIConfiguration.Async20();
case 'GRPC': return GRPCConfiguration.GRPC();
default: throw new Error(`Unknown API type: ${type}`);
Expand Down
122 changes: 107 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api-components/api-model-generator",
"version": "0.3.1",
"version": "0.4.0",
"description": "AMF model generator for API components",
"main": "index.js",
"scripts": {
Expand All @@ -16,7 +16,7 @@
"Francisco Di Giandomenico"
],
"dependencies": {
"amf-client-js": "^5.10.2",
"amf-client-js": "5.11.12531",
"fs-extra": "^10.0.0"
},
"devDependencies": {
Expand Down
89 changes: 89 additions & 0 deletions test/api-generation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,95 @@ describe('API generation', () => {
});
});

describe('OAS 3.1 data model generation', () => {
let files;
let opts;

const modelFile = path.join(dest, 'oas31-webhooks.json');
const compactModelFile = path.join(dest, 'oas31-webhooks-compact.json');
const config = { 'type': 'OAS 3.1', 'mime': 'application/yaml' };

beforeEach(() => {
files = new Map();
opts = {
src: srcDir,
dest,
};
});

afterEach(() => fs.remove(dest));

it('Generates data model for regular model', async () => {
files.set('apis/oas31-webhooks.yaml', config);
await generator(files, opts);
const exists = await fs.pathExists(modelFile);
assert.isTrue(exists, 'model file exists');
const data = await fs.readJson(modelFile);
assertValidAmfModel(data);
});

it('Generates data model for compact model', async () => {
files.set('apis/oas31-webhooks.yaml', config);
await generator(files, opts);
const exists = await fs.pathExists(compactModelFile);
assert.isTrue(exists, 'model file exists');
const data = await fs.readJson(compactModelFile);
assertValidAmfModel(data);
});

it('Emits webhooks as first-class operations', async () => {
files.set('apis/oas31-webhooks.yaml', config);
await generator(files, opts);
const raw = await fs.readFile(compactModelFile, 'utf8');
assert.include(raw, 'Webhook', 'compact model references a Webhook');
});
});

describe('OAS 3.2 data model generation', () => {
let files;
let opts;

const modelFile = path.join(dest, 'oas32-query-sse.json');
const compactModelFile = path.join(dest, 'oas32-query-sse-compact.json');
const config = { 'type': 'OAS 3.2', 'mime': 'application/yaml' };

beforeEach(() => {
files = new Map();
opts = {
src: srcDir,
dest,
};
});

afterEach(() => fs.remove(dest));

it('Generates data model for regular model', async () => {
files.set('apis/oas32-query-sse.yaml', config);
await generator(files, opts);
const exists = await fs.pathExists(modelFile);
assert.isTrue(exists, 'model file exists');
const data = await fs.readJson(modelFile);
assertValidAmfModel(data);
});

it('Generates data model for compact model', async () => {
files.set('apis/oas32-query-sse.yaml', config);
await generator(files, opts);
const exists = await fs.pathExists(compactModelFile);
assert.isTrue(exists, 'model file exists');
const data = await fs.readJson(compactModelFile);
assertValidAmfModel(data);
});

it('Parses the QUERY method and SSE media type', async () => {
files.set('apis/oas32-query-sse.yaml', config);
await generator(files, opts);
const raw = await fs.readFile(compactModelFile, 'utf8');
assert.include(raw, 'QUERY', 'compact model references the QUERY method');
assert.include(raw, 'event-stream', 'compact model references the SSE media type');
});
});

describe('generator.generate()', () => {
let opts;

Expand Down
Loading
Loading