Skip to content

Commit e78428d

Browse files
authored
Merge branch 'master' into all-contributors/add-istvan-nagy-epam
2 parents 6ea2e7d + 302a846 commit e78428d

File tree

10 files changed

+42
-17
lines changed

10 files changed

+42
-17
lines changed

examples/java-generate-jakarta-constraint-annotation/__snapshots__/index.spec.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Array [
99
@NotNull
1010
@Max(99)
1111
private double maxNumberProp;
12+
@Valid
1213
@Size(min=2, max=3)
1314
private Object[] arrayProp;
1415
@Pattern(regexp=\\"^I_\\")

examples/java-generate-javax-constraint-annotation/__snapshots__/index.spec.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Array [
99
@NotNull
1010
@Max(99)
1111
private double maxNumberProp;
12+
@Valid
1213
@Size(min=2, max=3)
1314
private Object[] arrayProp;
1415
@Pattern(regexp=\\"^I_\\")

modelina-cli/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ $ npm install -g @asyncapi/modelina-cli
162162
$ modelina COMMAND
163163
running command...
164164
$ modelina (--version)
165-
@asyncapi/modelina-cli/4.0.0-next.65 linux-x64 node-v18.20.5
165+
@asyncapi/modelina-cli/4.0.0 linux-x64 node-v18.20.6
166166
$ modelina --help [COMMAND]
167167
USAGE
168168
$ modelina COMMAND
@@ -240,7 +240,7 @@ DESCRIPTION
240240
CLI config settings
241241
```
242242

243-
_See code: [src/commands/config/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/index.ts)_
243+
_See code: [src/commands/config/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/index.ts)_
244244

245245
## `modelina config context`
246246

@@ -254,7 +254,7 @@ DESCRIPTION
254254
Manage short aliases for full paths to inputs
255255
```
256256

257-
_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/index.ts)_
257+
_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/index.ts)_
258258

259259
## `modelina config context add CONTEXT-NAME SPEC-FILE-PATH`
260260

@@ -276,7 +276,7 @@ DESCRIPTION
276276
Add a context to the store
277277
```
278278

279-
_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/add.ts)_
279+
_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/add.ts)_
280280

281281
## `modelina config context current`
282282

@@ -293,7 +293,7 @@ DESCRIPTION
293293
Shows the current context that is being used
294294
```
295295

296-
_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/current.ts)_
296+
_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/current.ts)_
297297

298298
## `modelina config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH`
299299

@@ -314,7 +314,7 @@ DESCRIPTION
314314
Edit a context in the store
315315
```
316316

317-
_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/edit.ts)_
317+
_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/edit.ts)_
318318

319319
## `modelina config context init [CONTEXT-FILE-PATH]`
320320

@@ -337,7 +337,7 @@ DESCRIPTION
337337
Initialize context
338338
```
339339

340-
_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/init.ts)_
340+
_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/init.ts)_
341341

342342
## `modelina config context list`
343343

@@ -354,7 +354,7 @@ DESCRIPTION
354354
List all the stored contexts in the store
355355
```
356356

357-
_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/list.ts)_
357+
_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/list.ts)_
358358

359359
## `modelina config context remove CONTEXT-NAME`
360360

@@ -374,7 +374,7 @@ DESCRIPTION
374374
Delete a context from the store
375375
```
376376

377-
_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/remove.ts)_
377+
_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/remove.ts)_
378378

379379
## `modelina config context use CONTEXT-NAME`
380380

@@ -394,7 +394,7 @@ DESCRIPTION
394394
Set a context as current
395395
```
396396

397-
_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/config/context/use.ts)_
397+
_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/config/context/use.ts)_
398398

399399
## `modelina generate LANGUAGE FILE`
400400

@@ -458,7 +458,7 @@ DESCRIPTION
458458
Generates typed models
459459
```
460460

461-
_See code: [src/commands/generate.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.65/modelina-cli/src/commands/generate.ts)_
461+
_See code: [src/commands/generate.ts](https://github.com/asyncapi/modelina/blob/v4.0.0/modelina-cli/src/commands/generate.ts)_
462462

463463
## `modelina help [COMMAND]`
464464

modelina-cli/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modelina-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@asyncapi/modelina-cli",
33
"description": "CLI to work with Modelina",
4-
"version": "4.0.0",
4+
"version": "4.0.1",
55
"bin": {
66
"modelina": "./bin/run_bin"
77
},

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@asyncapi/modelina",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents",
55
"license": "Apache-2.0",
66
"homepage": "https://www.modelina.org",

src/generators/java/presets/ConstraintsPreset.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {
22
ConstrainedArrayModel,
33
ConstrainedFloatModel,
44
ConstrainedIntegerModel,
5+
ConstrainedObjectModel,
6+
ConstrainedReferenceModel,
57
ConstrainedStringModel
68
} from '../../../models';
79
import { JavaPreset } from '../JavaPreset';
@@ -33,6 +35,15 @@ export const JAVA_CONSTRAINTS_PRESET: JavaPreset<JavaConstraintsPresetOptions> =
3335

3436
const annotations: string[] = [];
3537

38+
// needs cascade validation
39+
if (
40+
property.property instanceof ConstrainedReferenceModel ||
41+
property.property instanceof ConstrainedObjectModel ||
42+
property.property instanceof ConstrainedArrayModel
43+
) {
44+
annotations.push(renderer.renderAnnotation('Valid'));
45+
}
46+
3647
if (property.required) {
3748
annotations.push(renderer.renderAnnotation('NotNull'));
3849
}

test/generators/java/__snapshots__/JavaGenerator.spec.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public interface Vehicle {
196196
exports[`JavaGenerator oneOf/discriminator with jackson preset date-time format should render java.time.OffsetDateTime 1`] = `
197197
Array [
198198
"public class Event {
199+
@Valid
199200
@NotNull
200201
@JsonProperty(\\"action\\")
201202
private Action action;
@@ -311,6 +312,7 @@ public interface Pet {
311312
@NotNull
312313
@JsonProperty(\\"specversion\\")
313314
private final String specversion = \\"1.0\\";
315+
@Valid
314316
@NotNull
315317
@JsonProperty(\\"type\\")
316318
private final CloudEventType type = CloudEventType.DOG;
@@ -431,6 +433,7 @@ public interface Pet {
431433
@NotNull
432434
@JsonProperty(\\"specversion\\")
433435
private final String specversion = \\"1.0\\";
436+
@Valid
434437
@NotNull
435438
@JsonProperty(\\"type\\")
436439
private final CloudEventType type = CloudEventType.CAT;
@@ -521,6 +524,7 @@ Array [
521524
@NotNull
522525
@JsonProperty(\\"id\\")
523526
private String id;
527+
@Valid
524528
@NotNull
525529
@JsonProperty(\\"type\\")
526530
private final CloudEventType type = CloudEventType.DOG;
@@ -623,6 +627,7 @@ public interface Pet {
623627
624628
}",
625629
"public class Dog implements Pet {
630+
@Valid
626631
@NotNull
627632
@JsonProperty(\\"type\\")
628633
private final DogType type = DogType.DOG;
@@ -704,6 +709,7 @@ public interface Pet {
704709
}
705710
}",
706711
"public class Cat implements Pet {
712+
@Valid
707713
@NotNull
708714
@JsonProperty(\\"type\\")
709715
private final CatType type = CatType.CAT;
@@ -801,6 +807,7 @@ public interface Vehicle {
801807
VehicleType getVehicleType();
802808
}",
803809
"public class Cargo {
810+
@Valid
804811
@JsonProperty(\\"vehicle\\")
805812
@JsonInclude(JsonInclude.Include.NON_NULL)
806813
private Vehicle vehicle;
@@ -854,6 +861,7 @@ public interface Vehicle {
854861
}
855862
}",
856863
"public class Car implements Vehicle {
864+
@Valid
857865
@NotNull
858866
@JsonProperty(\\"vehicleType\\")
859867
private final VehicleType vehicleType = VehicleType.CAR;
@@ -935,6 +943,7 @@ public interface Vehicle {
935943
}
936944
}",
937945
"public class Truck implements Vehicle {
946+
@Valid
938947
@NotNull
939948
@JsonProperty(\\"vehicleType\\")
940949
private final VehicleType vehicleType = VehicleType.TRUCK;

test/generators/java/presets/__snapshots__/ConstraintsPreset.spec.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ exports[`JAVA_CONSTRAINTS_PRESET should render jakarta constraints annotations f
3030
@NotNull
3131
@Max(99)
3232
private double maxNumberProp;
33+
@Valid
3334
@Size(min=2, max=3)
3435
private Object[] arrayProp;
3536
@Pattern(regexp=\\"^\\\\\\\\w+(\\\\\\"\\\\\\\\.\\\\\\\\w+)*$\\")
@@ -62,6 +63,7 @@ exports[`JAVA_CONSTRAINTS_PRESET should render javax constraints annotations by
6263
@NotNull
6364
@Max(99)
6465
private double maxNumberProp;
66+
@Valid
6567
@Size(min=2, max=3)
6668
private Object[] arrayProp;
6769
@Pattern(regexp=\\"^\\\\\\\\w+(\\\\\\"\\\\\\\\.\\\\\\\\w+)*$\\")
@@ -94,6 +96,7 @@ exports[`JAVA_CONSTRAINTS_PRESET should render javax constraints annotations whe
9496
@NotNull
9597
@Max(99)
9698
private double maxNumberProp;
99+
@Valid
97100
@Size(min=2, max=3)
98101
private Object[] arrayProp;
99102
@Pattern(regexp=\\"^\\\\\\\\w+(\\\\\\"\\\\\\\\.\\\\\\\\w+)*$\\")

0 commit comments

Comments
 (0)