File tree Expand file tree Collapse file tree 6 files changed +143
-3
lines changed Expand file tree Collapse file tree 6 files changed +143
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 0.9.7 Released on 2022-08-15
4
+
5
+ - change rule 'TypeChanged' to 'Info' if adding 'type: object ' to an schema with "properties".
6
+
3
7
## 0.9.6 Released on 2022-06-09
4
8
5
9
- using autorest v3.6.1'.
Original file line number Diff line number Diff line change
1
+ {
2
+ "swagger" : 2.0 ,
3
+ "info" : {
4
+ "title" : " type_changed" ,
5
+ "version" : " 1.0"
6
+ },
7
+ "host" : " localhost:8000" ,
8
+ "schemes" : [ " http" , " https" ],
9
+ "consumes" : [ " text/plain" , " text/json" ],
10
+ "produces" : [ " text/plain" ],
11
+ "paths" : {
12
+ "/api/Parameters" : {
13
+ "put" : {
14
+ "tag" : [ " Parameters" ],
15
+ "operationId" : " Parameters_Put" ,
16
+ "produces" : [
17
+ " text/plain"
18
+ ],
19
+ "parameters" : [
20
+ {
21
+ "name" : " database" ,
22
+ "in" : " body" ,
23
+ "required" : true ,
24
+ "type" : " object" ,
25
+ "schema" : { "$ref" : " #/definitions/Database" }
26
+ }
27
+ ]
28
+ }
29
+ }
30
+ },
31
+ "definitions" : {
32
+ "Database" : {
33
+ "properties" : {
34
+ "a" : {
35
+ "type" : " object" ,
36
+ "readOnly" : true ,
37
+ "properties" : {
38
+ "b" : {
39
+ "type" : " string" ,
40
+ "readOnly" : true
41
+ }
42
+ },
43
+ "description" : " This is a system generated property.\n The _rid value is empty for this operation."
44
+ },
45
+ "b" : {
46
+ "type" : " integer" ,
47
+ "readOnly" : true ,
48
+ "default" : 0 ,
49
+ "description" : " This property shows the number of databases returned."
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "swagger" : 2.0 ,
3
+ "info" : {
4
+ "title" : " type_changed" ,
5
+ "version" : " 1.0"
6
+ },
7
+ "host" : " localhost:8000" ,
8
+ "schemes" : [ " http" , " https" ],
9
+ "consumes" : [ " text/plain" , " text/json" ],
10
+ "produces" : [ " text/plain" ],
11
+ "paths" : {
12
+ "/api/Parameters" : {
13
+ "put" : {
14
+ "tag" : [ " Parameters" ],
15
+ "operationId" : " Parameters_Put" ,
16
+ "produces" : [
17
+ " text/plain"
18
+ ],
19
+ "parameters" : [
20
+ {
21
+ "name" : " database" ,
22
+ "in" : " body" ,
23
+ "required" : true ,
24
+ "type" : " object" ,
25
+ "schema" : { "$ref" : " #/definitions/Database" }
26
+ }
27
+ ]
28
+ }
29
+ }
30
+ },
31
+ "definitions" : {
32
+ "Database" : {
33
+ "properties" : {
34
+ "a" : {
35
+ "readOnly" : true ,
36
+ "properties" : {
37
+ "b" : {
38
+ "type" : " string" ,
39
+ "readOnly" : true
40
+ }
41
+ },
42
+ "description" : " This is a system generated property.\n The _rid value is empty for this operation."
43
+ },
44
+ "b" : {
45
+ "type" : " integer" ,
46
+ "readOnly" : true ,
47
+ "default" : 0 ,
48
+ "description" : " This property shows the number of databases returned."
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
Original file line number Diff line number Diff line change @@ -150,6 +150,21 @@ public void PropertyTypeChanged()
150
150
Assert . Equal ( "new/type_changed.json#/definitions/Database/properties/a" , error . NewJsonRef ) ;
151
151
}
152
152
153
+ /// <summary>
154
+ /// Verifies that if adding a 'type:object' to a schema with 'properties', it's not error.
155
+ /// </summary>
156
+ [ Fact ]
157
+ public void TypeObjectChanged ( )
158
+ {
159
+ var messages = CompareSwagger ( "type_changed_01.json" ) . ToArray ( ) ;
160
+ var missing = messages . Where ( m => m . Id == ComparisonMessages . TypeChanged . Id ) ;
161
+ Assert . NotEmpty ( missing ) ;
162
+ var error = missing . Where ( err => err . NewJsonRef . StartsWith ( "new/type_changed_01.json#/definitions/" ) ) . FirstOrDefault ( ) ;
163
+ Assert . NotNull ( error ) ;
164
+ Assert . Equal ( Category . Info , error . Severity ) ;
165
+ Assert . Equal ( "new/type_changed_01.json#/definitions/Database/properties/a" , error . NewJsonRef ) ;
166
+ }
167
+
153
168
/// <summary>
154
169
/// Verifies that if you change the type format of a schema property, it's caught.
155
170
/// </summary>
Original file line number Diff line number Diff line change @@ -127,12 +127,26 @@ T previous
127
127
128
128
// Are the types the same?
129
129
130
- if ( prior . Type . HasValue != Type . HasValue || ( Type . HasValue && prior . Type . Value != Type . Value ) )
130
+ if ( ( Type . HasValue && prior . Type . HasValue && prior . Type . Value != Type . Value ) )
131
131
{
132
- context . LogBreakingChange ( ComparisonMessages . TypeChanged ,
132
+ context . LogError ( ComparisonMessages . TypeChanged ,
133
133
Type . HasValue ? Type . Value . ToString ( ) . ToLower ( ) : "" ,
134
134
prior . Type . HasValue ? prior . Type . Value . ToString ( ) . ToLower ( ) : "" ) ;
135
135
}
136
+ var isObject = Type . HasValue && Type . Value == DataType . Object && ( this is Schema ) ? ( this as Schema ) . Properties != null : false ;
137
+ if ( prior . Type . HasValue != Type . HasValue ) {
138
+ if ( ! prior . Type . HasValue && Type . HasValue && isObject )
139
+ {
140
+ context . LogInfo ( ComparisonMessages . TypeChanged ,
141
+ Type . HasValue ? Type . Value . ToString ( ) . ToLower ( ) : "" ,
142
+ prior . Type . HasValue ? prior . Type . Value . ToString ( ) . ToLower ( ) : "" ) ;
143
+ }
144
+ else {
145
+ context . LogError ( ComparisonMessages . TypeChanged ,
146
+ Type . HasValue ? Type . Value . ToString ( ) . ToLower ( ) : "" ,
147
+ prior . Type . HasValue ? prior . Type . Value . ToString ( ) . ToLower ( ) : "" ) ;
148
+ }
149
+ }
136
150
137
151
// What about the formats?
138
152
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @azure/oad" ,
3
- "version" : " 0.9.6 " ,
3
+ "version" : " 0.9.7 " ,
4
4
"author" : {
5
5
"name" : " Microsoft Corporation" ,
6
6
You can’t perform that action at this time.
0 commit comments