Skip to content

Commit

Permalink
Merge branch 'next' into enable_v3
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni authored Nov 14, 2023
2 parents 343ed82 + 52fd126 commit 63288a1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 4 deletions.
62 changes: 62 additions & 0 deletions docs/migrations/version-2-to-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Migration from v2 to v3

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

### TypeScript

Is not affected by this change.

### JavaScript

Is not affected by this change.

### C#

Is not affected by this change.

### Java

#### java.time.Duration is used when format is duration

This example used to generate a `String`, but is now instead using `java.time.Duration`.

```yaml
type: object
properties:
duration:
type: string
format: duration
```
will generate
```java
public class TestClass {
private java.time.Duration duration;
...
}
```

### Kotlin

Is not affected by this change.

### Rust

Is not affected by this change.

### Python

Is not affected by this change.

### Go

Is not affected by this change.

### Dart

Is not affected by this change.

### C++

Is not affected by this change.
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ module.exports = {
'<rootDir>/test/generators/template',
'<rootDir>/test/processors/TemplateInputProcessor.spec.ts',
'modelina-website'
]
],
watchPathIgnorePatterns: ['<rootDir>/node_modules']
};
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@asyncapi/modelina",
"version": "2.0.2",
"version": "3.0.0-next.1",
"description": "Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents",
"license": "Apache-2.0",
"homepage": "https://www.modelina.org",
Expand Down
2 changes: 2 additions & 0 deletions src/generators/java/JavaConstrainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ export const JavaDefaultTypeMapping: JavaTypeMapping = {
case 'dateTime':
case 'date-time':
return 'java.time.OffsetDateTime';
case 'duration':
return 'java.time.Duration';
case 'binary':
return 'byte[]';
default:
Expand Down
13 changes: 13 additions & 0 deletions test/generators/java/JavaConstrainer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,19 @@ describe('JavaConstrainer', () => {
});
expect(type).toEqual('byte[]');
});
test('should render Duration when format has duration format', () => {
const model = new ConstrainedStringModel(
'test',
{},
{ format: 'duration' },
''
);
const type = JavaDefaultTypeMapping.String({
constrainedModel: model,
...defaultOptions
});
expect(type).toEqual('java.time.Duration');
});
});
describe('Boolean', () => {
test('should render type', () => {
Expand Down

0 comments on commit 63288a1

Please sign in to comment.