Skip to content

Commit

Permalink
Lint fix, migrations doc update and package-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jano-petras committed Nov 17, 2023
1 parent 313c025 commit 2e936c3
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
63 changes: 62 additions & 1 deletion docs/migrations/version-2-to-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,68 @@ Is not affected by this change.

### C#

Is not affected by this change.
#### System.TimeSpan is used when format is time

This example used to generate a `string`, but is now instead using `System.TimeSpan`.

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

#### System.DateTime is used when format is date-time

This example used to generate a `string`, but is now instead using `System.DateTime`.

```yaml
type: object
properties:
dob:
type: string
format: date-time
```
will generate
```csharp
public class TestClass {
private System.DateTime dob;
...
}
```

#### System.Guid is used when format is uuid

This example used to generate a `string`, but is now instead using `System.Guid`.

```yaml
type: object
properties:
uniqueId:
type: string
format: uuid
```
will generate
```csharp
public class TestClass {
private System.Guid uniqueId;
...
}
```

### Java

Expand Down
2 changes: 1 addition & 1 deletion examples/generate-csharp-models/package-lock.json

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

21 changes: 18 additions & 3 deletions test/generators/csharp/CSharpConstrainer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,38 @@ describe('CSharpConstrainer', () => {
expect(type).toEqual('string');
});
test('should render System.DateTime', () => {
const model = new ConstrainedStringModel('test', undefined, { format: 'date-time' }, '');
const model = new ConstrainedStringModel(
'test',
undefined,
{ format: 'date-time' },
''
);
const type = CSharpDefaultTypeMapping.String({
constrainedModel: model,
...defaultOptions
});
expect(type).toEqual('System.DateTime');
});
test('should render TimeSpan', () => {
const model = new ConstrainedStringModel('test', undefined, { format: 'time' }, '');
const model = new ConstrainedStringModel(
'test',
undefined,
{ format: 'time' },
''
);
const type = CSharpDefaultTypeMapping.String({
constrainedModel: model,
...defaultOptions
});
expect(type).toEqual('System.TimeSpan');
});
test('should render Guid', () => {
const model = new ConstrainedStringModel('test', undefined, { format: 'uuid' }, '');
const model = new ConstrainedStringModel(
'test',
undefined,
{ format: 'uuid' },
''
);
const type = CSharpDefaultTypeMapping.String({
constrainedModel: model,
...defaultOptions
Expand Down

0 comments on commit 2e936c3

Please sign in to comment.