Skip to content

Commit de7708e

Browse files
authored
Merge pull request #119 from antmendoza/ignore-functions-on-validation
ignore additionalProperties when are declared as function
2 parents a6903ad + 6957eeb commit de7708e

26 files changed

+75
-50
lines changed

src/lib/definitions/callbackstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class Callbackstate {
109109
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
110110
* @returns {Specification.Callbackstate} without deleted properties.
111111
*/
112-
normalize(): Callbackstate {
112+
normalize = (): Callbackstate => {
113113
const clone = new Callbackstate(this);
114114

115115
normalizeUsedForCompensationProperty(clone);
@@ -120,5 +120,5 @@ export class Callbackstate {
120120
setEndValueIfNoTransition(clone);
121121

122122
return clone;
123-
}
123+
};
124124
}

src/lib/definitions/databasedswitch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ export class Databasedswitch {
8383
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
8484
* @returns {Specification.Databasedswitch} without deleted properties.
8585
*/
86-
normalize(): Databasedswitch {
86+
normalize = (): Databasedswitch => {
8787
const clone = new Databasedswitch(this);
8888

8989
normalizeUsedForCompensationProperty(clone);
9090
normalizeOnErrorsProperty(clone);
9191
normalizeDataConditionsProperty(clone);
9292

9393
return clone;
94-
}
94+
};
9595
}

src/lib/definitions/defaultdef.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export class Defaultdef /* Default definition. Can be either a transition or end
3838
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
3939
* @returns {Specification.Defaultdef} without deleted properties.
4040
*/
41-
normalize(): Defaultdef {
41+
normalize = (): Defaultdef => {
4242
const clone = new Defaultdef(this);
4343

4444
normalizeEndProperty(clone);
4545
normalizeTransitionProperty(clone);
4646
setEndValueIfNoTransition(clone);
4747

4848
return clone;
49-
}
49+
};
5050
}

src/lib/definitions/delaystate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class Delaystate {
9292
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
9393
* @returns {Specification.Delaystate} without deleted properties.
9494
*/
95-
normalize(): Delaystate {
95+
normalize = (): Delaystate => {
9696
const clone = new Delaystate(this);
9797

9898
normalizeUsedForCompensationProperty(clone);
@@ -101,5 +101,5 @@ export class Delaystate {
101101
normalizeTransitionProperty(clone);
102102
setEndValueIfNoTransition(clone);
103103
return clone;
104-
}
104+
};
105105
}

src/lib/definitions/end.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ export class End {
4444
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
4545
* @returns {Specification.End} without deleted properties.
4646
*/
47-
normalize(): End {
47+
normalize = (): End => {
4848
const clone = new End(this);
4949

5050
normalizeCompensateProperty(clone);
5151
normalizeTerminateProperty(clone);
5252

5353
return clone;
54-
}
54+
};
5555
}

src/lib/definitions/enddatacondition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ export class Enddatacondition {
4343
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
4444
* @returns {Specification.Enddatacondition} without deleted properties.
4545
*/
46-
normalize(): Enddatacondition {
46+
normalize = (): Enddatacondition => {
4747
const clone = new Enddatacondition(this);
4848

4949
normalizeEndProperty(clone);
5050

5151
return clone;
52-
}
52+
};
5353
}

src/lib/definitions/enddeventcondition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export class Enddeventcondition {
5555
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
5656
* @returns {Specification.Enddeventcondition} without deleted properties.
5757
*/
58-
normalize(): Enddeventcondition {
58+
normalize = (): Enddeventcondition => {
5959
const clone = new Enddeventcondition(this);
6060

6161
normalizeEndProperty(clone);
6262

6363
return clone;
64-
}
64+
};
6565
}

src/lib/definitions/error.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class Error {
5050
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
5151
* @returns {Specification.Error} without deleted properties.
5252
*/
53-
normalize(): Error {
53+
normalize = (): Error => {
5454
const clone = new Error(this);
5555

5656
normalizeEndProperty(clone);
@@ -59,5 +59,5 @@ export class Error {
5959
setEndValueIfNoTransition(clone);
6060

6161
return clone;
62-
}
62+
};
6363
}

src/lib/definitions/eventbasedswitch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ export class Eventbasedswitch {
9090
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
9191
* @returns {Specification.Eventbasedswitch} without deleted properties.
9292
*/
93-
normalize(): Eventbasedswitch {
93+
normalize = (): Eventbasedswitch => {
9494
const clone = new Eventbasedswitch(this);
9595

9696
normalizeUsedForCompensationProperty(clone);
9797
normalizeOnErrorsProperty(clone);
9898
normalizeEventConditionsProperty(clone);
9999

100100
return clone;
101-
}
101+
};
102102
}

src/lib/definitions/eventdef.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ export class Eventdef {
5757
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
5858
* @returns {Specification.Eventdef} without deleted properties.
5959
*/
60-
normalize(): Eventdef {
60+
normalize = (): Eventdef => {
6161
const clone = new Eventdef(this);
6262

6363
normalizeKindProperty(clone);
6464

6565
return clone;
66-
}
66+
};
6767
}

src/lib/definitions/eventstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class Eventstate /* This state is used to wait for events from event sour
8888
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
8989
* @returns {Specification.Eventstate} without deleted properties.
9090
*/
91-
normalize(): Eventstate {
91+
normalize = (): Eventstate => {
9292
const clone = new Eventstate(this);
9393

9494
normalizeExclusiveProperty(clone);
@@ -99,5 +99,5 @@ export class Eventstate /* This state is used to wait for events from event sour
9999
setEndValueIfNoTransition(clone);
100100

101101
return clone;
102-
}
102+
};
103103
}

src/lib/definitions/exectimeout.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ export class Exectimeout {
3838
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
3939
* @returns {Specification.Exectimeout} without deleted properties.
4040
*/
41-
normalize(): Exectimeout {
41+
normalize = (): Exectimeout => {
4242
const clone = new Exectimeout(this);
4343

4444
normalizeInterruptProperty(clone);
4545

4646
return clone;
47-
}
47+
};
4848
}

src/lib/definitions/foreachstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class Foreachstate {
112112
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
113113
* @returns {Specification.Foreachstate} without deleted properties.
114114
*/
115-
normalize(): Foreachstate {
115+
normalize = (): Foreachstate => {
116116
const clone = new Foreachstate(this);
117117

118118
normalizeUsedForCompensationProperty(clone);
@@ -122,5 +122,5 @@ export class Foreachstate {
122122
setEndValueIfNoTransition(clone);
123123

124124
return clone;
125-
}
125+
};
126126
}

src/lib/definitions/function.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ export class Function {
3939
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
4040
* @returns {Specification.Function} without deleted properties.
4141
*/
42-
normalize(): Function {
42+
43+
normalize = (): Function => {
4344
const clone = new Function(this);
4445

4546
normalizeTypeRestProperty(clone);
4647

4748
return clone;
48-
}
49+
};
4950
}

src/lib/definitions/injectstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class Injectstate {
8383
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
8484
* @returns {Specification.Injectstate} without deleted properties.
8585
*/
86-
normalize(): Injectstate {
86+
normalize = (): Injectstate => {
8787
const clone = new Injectstate(this);
8888

8989
normalizeUsedForCompensationProperty(clone);
@@ -93,5 +93,5 @@ export class Injectstate {
9393
setEndValueIfNoTransition(clone);
9494

9595
return clone;
96-
}
96+
};
9797
}

src/lib/definitions/onevents.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export class Onevents {
4747
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
4848
* @returns {Specification.Onevents} without deleted properties.
4949
*/
50-
normalize(): Onevents {
50+
normalize = (): Onevents => {
5151
const clone = new Onevents(this);
5252

5353
normalizeActionModeParallelProperty(clone);
5454

5555
return clone;
56-
}
56+
};
5757
}

src/lib/definitions/operationstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class Operationstate {
101101
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
102102
* @returns {Specification.Operationstate} without deleted properties.
103103
*/
104-
normalize(): Operationstate {
104+
normalize = (): Operationstate => {
105105
const clone = new Operationstate(this);
106106

107107
normalizeActionModeSequentialProperty(clone);
@@ -112,5 +112,5 @@ export class Operationstate {
112112
setEndValueIfNoTransition(clone);
113113

114114
return clone;
115-
}
115+
};
116116
}

src/lib/definitions/parallelstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class Parallelstate {
105105
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
106106
* @returns {Specification.Parallelstate} without deleted properties.
107107
*/
108-
normalize(): Parallelstate {
108+
normalize = (): Parallelstate => {
109109
const clone = new Parallelstate(this);
110110

111111
normalizeCompletionTypeProperty(clone);
@@ -117,5 +117,5 @@ export class Parallelstate {
117117
setEndValueIfNoTransition(clone);
118118

119119
return clone;
120-
}
120+
};
121121
}

src/lib/definitions/repeat.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ export class Repeat {
5050
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
5151
* @returns {Specification.Repeat} without deleted properties.
5252
*/
53-
normalize(): Repeat {
53+
normalize = (): Repeat => {
5454
const clone = new Repeat(this);
5555

5656
normalizeContinueOnErrorProperty(clone);
5757
normalizeCheckBeforeProperty(clone);
5858

5959
return clone;
60-
}
60+
};
6161
}

src/lib/definitions/subflowstate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class Subflowstate {
104104
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
105105
* @returns {Specification.Subflowstate} without deleted properties.
106106
*/
107-
normalize(): Subflowstate {
107+
normalize = (): Subflowstate => {
108108
const clone = new Subflowstate(this);
109109

110110
normalizeUsedForCompensationProperty(clone);
@@ -119,5 +119,5 @@ export class Subflowstate {
119119
setEndValueIfNoTransition(clone);
120120

121121
return clone;
122-
}
122+
};
123123
}

src/lib/definitions/transition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ export class Transition {
4343
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
4444
* @returns {Specification.Transition} without deleted properties.
4545
*/
46-
normalize(): Transition {
46+
normalize = (): Transition => {
4747
const clone = new Transition(this);
4848

4949
normalizeCompensateProperty(clone);
5050

5151
return clone;
52-
}
52+
};
5353
}

src/lib/definitions/transitiondatacondition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ export class Transitiondatacondition {
4343
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
4444
* @returns {Specification.Transitiondatacondition} without deleted properties.
4545
*/
46-
normalize(): Transitiondatacondition {
46+
normalize = (): Transitiondatacondition => {
4747
const clone = new Transitiondatacondition(this);
4848

4949
normalizeTransitionProperty(clone);
5050

5151
return clone;
52-
}
52+
};
5353
}

src/lib/definitions/transitioneventcondition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export class Transitioneventcondition {
5454
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
5555
* @returns {Specification.Transitioneventcondition} without deleted properties.
5656
*/
57-
normalize(): Transitioneventcondition {
57+
normalize = (): Transitioneventcondition => {
5858
const clone = new Transitioneventcondition(this);
5959

6060
normalizeTransitionProperty(clone);
6161

6262
return clone;
63-
}
63+
};
6464
}

src/lib/definitions/workflow.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class Workflow {
9797
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
9898
* @returns {Specification.Workflow} without deleted properties.
9999
*/
100-
normalize(): Workflow {
100+
normalize = (): Workflow => {
101101
const clone = new Workflow(this);
102102
normalizeKeepActiveProperty(clone);
103103

@@ -110,7 +110,7 @@ export class Workflow {
110110

111111
normalizeExecTimeout(clone);
112112
return clone;
113-
}
113+
};
114114

115115
/**
116116
* Parses the provided string as Workflow
@@ -143,6 +143,6 @@ export class Workflow {
143143
*/
144144
static toYaml(workflow: Workflow): string {
145145
validate('Workflow', workflow);
146-
return yaml.dump(workflow.normalize());
146+
return yaml.dump(JSON.parse(JSON.stringify(workflow.normalize())));
147147
}
148148
}

src/lib/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const validate = (typeName: string, data: any): boolean => {
2929
throw Error(`Validate function not defined for type '${typeName}'`);
3030
}
3131

32-
if (!validateFn(data)) {
32+
if (!validateFn(JSON.parse(JSON.stringify(data)))) {
3333
console.warn(validateFn.errors);
3434
const firstError: DefinedError = (validateFn.errors as DefinedError[])[0];
3535
throw new Error(

0 commit comments

Comments
 (0)