@@ -3,7 +3,7 @@ import { DiagnosticSeverity } from '@stoplight/types';
33
44testRule ( 'xgen-IPA-123-enum-values-must-be-upper-snake-case' , [
55 {
6- name : 'valid schema - components.schemas' ,
6+ name : 'valid schema - components.schemas.property ' ,
77 document : {
88 components : {
99 schemas : {
@@ -21,18 +21,18 @@ testRule('xgen-IPA-123-enum-values-must-be-upper-snake-case', [
2121 errors : [ ] ,
2222 } ,
2323 {
24- name : 'invalid schema with exception - components.schemas' ,
24+ name : 'invalid schema with exception - components.schemas.property ' ,
2525 document : {
2626 components : {
2727 schemas : {
2828 SchemaName : {
29- 'x-xgen-IPA-exception' : {
30- 'xgen-IPA-123-enum-values-must-be-upper-snake-case' : 'reason' ,
31- } ,
3229 properties : {
3330 exampleProperty : {
3431 enum : [ 'exampleA' , 'exampleB' ] ,
3532 type : 'string' ,
33+ 'x-xgen-IPA-exception' : {
34+ 'xgen-IPA-123-enum-values-must-be-upper-snake-case' : 'reason' ,
35+ } ,
3636 } ,
3737 } ,
3838 } ,
@@ -42,7 +42,7 @@ testRule('xgen-IPA-123-enum-values-must-be-upper-snake-case', [
4242 errors : [ ] ,
4343 } ,
4444 {
45- name : 'invalid schema - components.schemas' ,
45+ name : 'invalid schema - components.schemas.property ' ,
4646 document : {
4747 components : {
4848 schemas : {
@@ -60,14 +60,72 @@ testRule('xgen-IPA-123-enum-values-must-be-upper-snake-case', [
6060 errors : [
6161 {
6262 code : 'xgen-IPA-123-enum-values-must-be-upper-snake-case' ,
63- message : 'exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
64- path : [ 'components' , 'schemas' , 'SchemaName' , 'properties' , 'exampleProperty' , 'enum' , '0' ] ,
63+ message : 'enum[0]:exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
64+ path : [ 'components' , 'schemas' , 'SchemaName' , 'properties' , 'exampleProperty' ] ,
65+ severity : DiagnosticSeverity . Warning ,
66+ } ,
67+ {
68+ code : 'xgen-IPA-123-enum-values-must-be-upper-snake-case' ,
69+ message : 'enum[1]:exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
70+ path : [ 'components' , 'schemas' , 'SchemaName' , 'properties' , 'exampleProperty' ] ,
71+ severity : DiagnosticSeverity . Warning ,
72+ } ,
73+ ] ,
74+ } ,
75+ {
76+ name : 'valid schema - components.schemas' ,
77+ document : {
78+ components : {
79+ schemas : {
80+ SchemaName : {
81+ enum : [ 'EXAMPLE_A' , 'EXAMPLE_B' ] ,
82+ type : 'string' ,
83+ } ,
84+ } ,
85+ } ,
86+ } ,
87+ errors : [ ] ,
88+ } ,
89+ {
90+ name : 'invalid schema with exception - components.schemas' ,
91+ document : {
92+ components : {
93+ schemas : {
94+ SchemaName : {
95+ 'x-xgen-IPA-exception' : {
96+ 'xgen-IPA-123-enum-values-must-be-upper-snake-case' : 'reason' ,
97+ } ,
98+ enum : [ 'exampleA' , 'exampleB' ] ,
99+ type : 'string' ,
100+ } ,
101+ } ,
102+ } ,
103+ } ,
104+ errors : [ ] ,
105+ } ,
106+ {
107+ name : 'invalid schema - components.schemas' ,
108+ document : {
109+ components : {
110+ schemas : {
111+ SchemaName : {
112+ enum : [ 'exampleA' , 'exampleB' ] ,
113+ type : 'string' ,
114+ } ,
115+ } ,
116+ } ,
117+ } ,
118+ errors : [
119+ {
120+ code : 'xgen-IPA-123-enum-values-must-be-upper-snake-case' ,
121+ message : 'enum[0]:exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
122+ path : [ 'components' , 'schemas' , 'SchemaName' ] ,
65123 severity : DiagnosticSeverity . Warning ,
66124 } ,
67125 {
68126 code : 'xgen-IPA-123-enum-values-must-be-upper-snake-case' ,
69- message : 'exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
70- path : [ 'components' , 'schemas' , 'SchemaName' , 'properties' , 'exampleProperty' , 'enum' , '1' ] ,
127+ message : 'enum[1]: exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
128+ path : [ 'components' , 'schemas' , 'SchemaName' ] ,
71129 severity : DiagnosticSeverity . Warning ,
72130 } ,
73131 ] ,
@@ -136,14 +194,14 @@ testRule('xgen-IPA-123-enum-values-must-be-upper-snake-case', [
136194 errors : [
137195 {
138196 code : 'xgen-IPA-123-enum-values-must-be-upper-snake-case' ,
139- message : 'exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
140- path : [ 'paths' , '/a/{exampleId}' , 'get' , 'parameters' , '0' , 'schema' , 'enum' , '0' ] ,
197+ message : 'enum[0]: exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
198+ path : [ 'paths' , '/a/{exampleId}' , 'get' , 'parameters' , '0' , 'schema' ] ,
141199 severity : DiagnosticSeverity . Warning ,
142200 } ,
143201 {
144202 code : 'xgen-IPA-123-enum-values-must-be-upper-snake-case' ,
145- message : 'exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
146- path : [ 'paths' , '/a/{exampleId}' , 'get' , 'parameters' , '0' , 'schema' , 'enum' , '1' ] ,
203+ message : 'enum[1]: exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123' ,
204+ path : [ 'paths' , '/a/{exampleId}' , 'get' , 'parameters' , '0' , 'schema' ] ,
147205 severity : DiagnosticSeverity . Warning ,
148206 } ,
149207 ] ,
0 commit comments