Skip to content
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e5a8172
chore: add migration docs (#2358)
jonaslagoni Nov 4, 2025
f6a213f
fix: move jsonproperty annotation to getter (#2359)
jonaslagoni Nov 4, 2025
f05e773
docs: add json schema docs and examples (#2360)
jonaslagoni Nov 4, 2025
c6c6716
fix: ci not working for mac and block release (#2364)
jonaslagoni Nov 4, 2025
a324bce
chore(release): v5.10.2-next.1 (#2365)
asyncapi-bot Nov 4, 2025
234cf9d
fix!: remove python deprecated option (#2363)
jonaslagoni Nov 4, 2025
cc17937
chore(release): v6.0.0-next.1 (#2366)
asyncapi-bot Nov 4, 2025
91b85c8
fix!: remove deprecated interpreter options (#2361)
jonaslagoni Nov 5, 2025
ee1c359
chore(release): v6.0.0-next.2 (#2368)
asyncapi-bot Nov 5, 2025
a1c2d61
feat!: improve anonym messages (#2367)
jonaslagoni Nov 5, 2025
8ef6b11
chore(release): v6.0.0-next.3 (#2370)
asyncapi-bot Nov 5, 2025
454bc04
feat: support non-object model types for Rust (#2372)
jadinm Nov 21, 2025
21068b8
chore(release): v6.0.0-next.4 (#2375)
asyncapi-bot Nov 21, 2025
07d0cbf
feat!: improve anonym names (#2378)
jonaslagoni Nov 30, 2025
c9c363a
chore: merge branch 'master' into next
jonaslagoni Dec 2, 2025
919e6ce
feat: update with master (#2380)
jonaslagoni Dec 2, 2025
5876835
feat: trigger release (#2381)
jonaslagoni Dec 2, 2025
9d436f5
feat: trigger release (#2382)
jonaslagoni Dec 3, 2025
97fa422
chore(release): v6.0.0-next.5 (#2383)
asyncapi-bot Dec 3, 2025
c192e80
Merge branch 'master' into next
jonaslagoni Dec 15, 2025
1d6e35a
fix!: typescript date mapping (#2393)
AarishMansur Dec 16, 2025
29eac76
fix: bunch of changes cross language (#2395)
jonaslagoni Dec 16, 2025
ab6232f
feat: upgrade node to v20 (#2434)
jonaslagoni Feb 8, 2026
9696fba
chore: add agents template (#2440)
jonaslagoni Feb 10, 2026
7a7454f
fix: upgrade node to v22 (#2441)
jonaslagoni Feb 10, 2026
daa2412
chore(release): v6.0.0-next.6 (#2442)
asyncapi-bot Feb 10, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/if-nodejs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
matrix:
# Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner.
# See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001
os: [ubuntu-latest, macos-13, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
run: |
Expand Down
13 changes: 0 additions & 13 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ This document contains many of the advanced use-cases that you may stumble upon
- [Change the generated indentation type and size](#change-the-generated-indentation-type-and-size)
- [Change the type mapping](#change-the-type-mapping)
- [Changing the constrain rules](#changing-the-constrain-rules)
- [Customizing the interpreter options](#customizing-the-interpreter-options)

<!-- tocstop -->

Expand Down Expand Up @@ -104,15 +103,3 @@ There can be multiple reasons why you want to change the default constrain rules
Check out this [example out for a live demonstration](../examples/overwrite-default-constraint/) for how to overwrite the default constraints.

Check out this [example out for a live demonstration](../examples/overwrite-naming-formatting/) for how to overwrite the naming formatting for models.

## Customizing the interpreter options

According to JSON schema draft 7, if `additionalProperties` or `additionalItems` are omitted, their default value is `true`. The `Interpreter` honors this behavior, however this creates more loose models that might not be the intention for the developer.

We suggest not using this option if it can be avoided, as it limits your generated models to include any additional properties, and would simply be ignored. Instead adapt your schemas to be more strict by setting these keywords to `false`. This option should really only be used when you have no control over your input and the output is unintended.

To set the interpreter up to ignore the default behavior, you can further restrict your models with the following options:
- `ignoreAdditionalProperties` - if set, it ensures that `additionalProperties` by default is ignored.
- `ignoreAdditionalItems` - if set, it ensures that `additionalItems` by default is ignored.

Check out this [example out for a live demonstration](../examples/passing-interpreter-options/) for how to customize the behavior of `additionalProperties`.
113 changes: 112 additions & 1 deletion docs/inputs/JSON_Schema.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,115 @@
# Interpretation of JSON Schema to CommonModel
# JSON Schema as an input

## Processor Options

The JSON Schema input processor provides several options to customize how schemas are interpreted into models. These options can be passed to the generator via the `processorOptions` parameter.

### Available Options

#### `interpretSingleEnumAsConst`
**Type**: `boolean` (default: `false`)

When enabled, a single enum value like `{enum: ['test']}` will be interpreted the same as `{const: 'test'}`. This reduces the number of enums being generated and uses constant values instead.

**Example**:
```typescript
const generator = new TypeScriptGenerator({
processorOptions: {
jsonSchema: {
interpretSingleEnumAsConst: true
}
}
});
```

See the [json-schema-single-enum-as-const example](../../examples/json-schema-single-enum-as-const) for a complete usage example.

#### `propertyNameForAdditionalProperties`
**Type**: `string` (default: `'additionalProperties'`)

Changes which property name should be used to represent `additionalProperties` in JSON Schema. This is useful when you want to customize the generated property name for additional properties in your models.

**Example**:
```typescript
const generator = new TypeScriptGenerator({
processorOptions: {
jsonSchema: {
propertyNameForAdditionalProperties: 'metadata'
}
}
});
```

See the [json-schema-additional-properties-representation example](../../examples/json-schema-additional-properties-representation) for a complete usage example.

#### `allowInheritance`
**Type**: `boolean` (default: `false`)

Enables support for inheritance in the generated models. When enabled, models can extend from other models based on the schema structure (such as `allOf` patterns).

**Example**:
```typescript
const generator = new TypeScriptGenerator({
processorOptions: {
jsonSchema: {
allowInheritance: true
}
}
});
```

See the [json-schema-allow-inheritance example](../../examples/json-schema-allow-inheritance) for a complete usage example.

#### `disableCache`
**Type**: `boolean` (default: `false`)

Disables the seenSchemas cache in the Interpreter. This option should only be used in specific internal scenarios and generally should not be modified by end users.

#### `ignoreAdditionalProperties`
**Type**: `boolean` (default: `false`)

For JSON Schema draft 7, `additionalProperties` are by default `true`, but this might create unintended properties in the models. Use this option to ignore default `additionalProperties` for models that have other properties defined with them.

**Note**: ONLY use this option if you do not have control over your schema files. Instead, adapt your schemas to be more strict by setting `additionalProperties: false`.

**Example**:
```typescript
const generator = new TypeScriptGenerator({
processorOptions: {
jsonSchema: {
ignoreAdditionalProperties: true
}
}
});
```

See the [json-schema-ignore-additional-properties example](../../examples/json-schema-ignore-additional-properties) for a complete usage example.

#### `ignoreAdditionalItems`
**Type**: `boolean` (default: `false`)

For JSON Schema draft 7, `additionalItems` are by default `true`, but this might create unintended types for arrays. Use this option to ignore default `additionalItems` for models as long as there are other types set for the array.

**Note**: ONLY use this option if you do not have control over the schema files you use to generate models from. Instead, you should adapt your schemas to be more strict by setting `additionalItems: false`.

**Example**:
```typescript
const generator = new TypeScriptGenerator({
processorOptions: {
jsonSchema: {
ignoreAdditionalItems: true
}
}
});
```

See the [json-schema-ignore-additional-items example](../../examples/json-schema-ignore-additional-items) for a complete usage example.

---

For a comprehensive example demonstrating multiple processor options together, see the [json-schema-processor-options example](../../examples/json-schema-processor-options).

## Interpretation of JSON Schema to CommonModel

The library transforms JSON Schema from data validation rules to data definitions (`CommonModel`(s)).

Expand Down
3 changes: 3 additions & 0 deletions docs/migrations/version-4-to-5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Migration from v4 to v5

There are no required changes to move from v4 to v5.
200 changes: 200 additions & 0 deletions docs/migrations/version-5-to-6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Migration from v5 to v6

This document contain all the breaking changes and migrations guidelines for adapting your code to the new version.

## Removed deprecated `interpreter` option from `ProcessorOptions`

The deprecated `interpreter` option has been removed from `ProcessorOptions`. You should now use the `jsonSchema` option instead.

**Before (v5):**
```typescript
const result = await generator.generate({
processorOptions: {
interpreter: {
// interpreter options
}
}
});
```

**After (v6):**
```typescript
const result = await generator.generate({
processorOptions: {
jsonSchema: {
// JSON Schema processor options
}
}
});
```
## Python

### Removal of deprecated `importsStyle` option

The `importsStyle` option was deprecated in v4 and has now been completely removed in v6. This option is no longer needed as all Python models now use explicit import style (`from . import ${model.name}`) to support circular model dependencies.

If you were still using this option in your code, simply remove it from your generator options:

```ts
// Before (v5 and earlier)
const generator = new PythonGenerator();
const models = await generator.generateCompleteModels(schema, {
importsStyle: 'explicit', // This option is no longer available
packageName: 'modelina'
});

// After (v6)
const generator = new PythonGenerator();
const models = await generator.generateCompleteModels(schema, {
packageName: 'modelina'
});
```

The generated Python code behavior remains unchanged - all imports will continue to use the explicit style.

## AsyncAPI

### Improved schema naming strategy

Modelina v6 introduces a significantly improved naming strategy for AsyncAPI schemas, providing more meaningful and context-aware names for generated models to minimize the amount of `Anonymous Schema`. If you have explicitly defined names for all models, this should not affect you.

#### Channel-based naming for inline message payloads

Inline message payloads (without explicit message names) now derive their names from the channel path instead of receiving generic anonymous names.

**Before (v5):**
```yaml
asyncapi: 2.0.0
channels:
/user/signedup:
subscribe:
message:
payload:
type: object
properties:
email:
type: string
```
Generated model: `AnonymousSchema_1` or `<anonymous-message-1>Payload`

**After (v6):**
Generated model: `UserSignedupPayload` (derived from channel path `/user/signedup`)

#### Hierarchical naming for nested schemas

Nested schemas in properties, `allOf`, `oneOf`, `anyOf`, `dependencies`, and `definitions` now receive hierarchical names based on their parent schema and property path.

**Before (v5):**
```yaml
components:
schemas:
MainSchema:
type: object
properties:
config:
type: object
properties:
setting:
type: string
```
Generated models: `MainSchema`, `AnonymousSchema_2`, `AnonymousSchema_3`

**After (v6):**
Generated models: `MainSchema`, `MainSchemaConfig`, `MainSchemaConfigSetting`

#### Improved handling of composition keywords

Schemas using `allOf`, `oneOf`, and `anyOf` now generate more descriptive names:

**Before (v5):**
```yaml
components:
schemas:
Pet:
oneOf:
- type: object
properties:
bark: { type: boolean }
- type: object
properties:
meow: { type: boolean }
```
Generated models: `Pet`, `AnonymousSchema_1`, `AnonymousSchema_2`

**After (v6):**
Generated models: `Pet`, `PetOneOfOption0`, `PetOneOfOption1`

#### Enhanced naming for special schema types

- **Array items**: `ParentSchemaItem` instead of `AnonymousSchema_N`
- **Pattern properties**: `ParentSchemaPatternProperty` instead of `AnonymousSchema_N`
- **Additional properties**: `ParentSchemaAdditionalProperty` instead of `AnonymousSchema_N`
- **Dependencies**: `ParentSchemaDependencyName` instead of `AnonymousSchema_N`
- **Definitions**: `ParentSchemaDefinitionName` instead of `AnonymousSchema_N`

### Multiple messages in operations now generate individual models

When processing AsyncAPI v3 documents with multiple messages in a single operation, Modelina now correctly generates individual models for each message payload in addition to the `oneOf` wrapper model.

**Example AsyncAPI Document:**
```yaml
asyncapi: 3.0.0
info:
title: User Service
version: 1.0.0
channels:
userEvents:
address: user/events
messages:
UserCreated:
$ref: '#/components/messages/UserCreated'
UserUpdated:
$ref: '#/components/messages/UserUpdated'
operations:
onUserEvents:
action: receive
channel:
$ref: '#/channels/userEvents'
messages:
- $ref: '#/channels/userEvents/messages/UserCreated'
- $ref: '#/channels/userEvents/messages/UserUpdated'
components:
messages:
UserCreated:
payload:
type: object
properties:
id:
type: string
name:
type: string
UserUpdated:
payload:
type: object
properties:
id:
type: string
name:
type: string
updatedAt:
type: string
```

**Before (v5):**
```typescript
const generator = new JavaGenerator();
const models = await generator.generate(inputModel);
// Problem: No UserCreated or UserUpdated classes were generated
```

**After (v6):**
```typescript
const generator = new JavaGenerator();
const models = await generator.generate(inputModel);
// ✓ Now generates:
// - UserCreatedPayload.java
// - UserUpdatedPayload.java
// - userEvents interface (discriminated union)
```

No code changes are required. This is an enhancement that fixes incomplete model generation. If you have custom post-processing logic that filters generated models, you may need to adjust it to handle the additional models.
12 changes: 12 additions & 0 deletions docs/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Modelina uses something called **presets** to extend the rendered model. You can
- [**Package**](#package)
- [**Union**](#union)
- [**Tuple**](#tuple)
- [**NewType**](#newtype)
+ [Dart](#dart)
- [**Class**](#class-4)
- [**Enum**](#enum-5)
Expand Down Expand Up @@ -496,6 +497,17 @@ This preset is a generator for the meta model `ConstrainedTupleModel` and [can b
| `field` | | `field` object as a [`ConstrainedTupleValueModel`](./internal-model.md#the-constrained-meta-model) instance, `fieldIndex`. |
| `structMacro` | | `field` object as a [`ConstrainedTupleValueModel`](./internal-model.md#the-constrained-meta-model) instance, `fieldIndex`. |

#### **NewType**

This preset is a generator for the meta model `ConstrainedMetaModel` and [can be accessed through the `model` argument](#presets-shape).
This preset is called each time the [New Type pattern](https://doc.rust-lang.org/rust-by-example/generics/new_types.html) is used to wrap
non-object models (i.e., boolean, integers, floats, strings or arrays).

| Method | Description | Additional arguments |
|---|---|---|
| `field` | A method to extend rendered the only field: the wrapped model. | |
| `structMacro` | | |

### Dart
#### **Class**

Expand Down
Loading
Loading