Skip to content

Commit 000f1f7

Browse files
jianyexijianyexi
and
jianyexi
authored
fix adding enum value & command line exception (#255)
* fix adding enum value & command line exception * fix lint error * fix test * fix test * fix file path contains space * fix lint error Co-authored-by: jianyexi <[email protected]>
1 parent 185090c commit 000f1f7

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

openapi-diff/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerCompareTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ public void CommonParameterWithRef()
878878
public void XmsEnumModelAsString()
879879
{
880880
var messages = CompareSwagger("enum_as_string.json").ToArray();
881-
Assert.Empty(messages.Where(m => m.Id == ComparisonMessages.AddedEnumValue.Id));
881+
Assert.Equal(2,messages.Where(m => m.Id == ComparisonMessages.AddedEnumValue.Id).ToList().Count());
882882
}
883883

884884
[Fact]

openapi-diff/src/modeler/AutoRest.Swagger/Model/SwaggerObject.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ private void CompareEnums(ComparisonContext<ServiceDefinition> context, T prior)
187187
CompareXmsEnum(context,prior);
188188
bool relaxes = (prior.Enum != null && this.Enum == null);
189189
bool constrains = (prior.Enum == null && this.Enum != null);
190-
bool isEnumModelAsString = (this.XmsEnum != null && this.XmsEnum.ModelAsString == true);
191190
if (!relaxes && !constrains)
192191
{
193192
// It was enum and it is still enum i.e check for addition/removal
@@ -213,9 +212,7 @@ private void CompareEnums(ComparisonContext<ServiceDefinition> context, T prior)
213212
IEnumerable<string> addedEnums = this.Enum.Except(prior.Enum);
214213
if (addedEnums.Any())
215214
{
216-
if (!isEnumModelAsString) {
217-
context.LogBreakingChange(ComparisonMessages.AddedEnumValue, String.Join(", ", addedEnums.ToList()));
218-
}
215+
context.LogBreakingChange(ComparisonMessages.AddedEnumValue, String.Join(", ", addedEnums.ToList()));
219216
}
220217
}
221218
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure/oad",
3-
"version": "0.10.2",
3+
"version": "0.10.3",
44
"author": {
55
"name": "Microsoft Corporation",
66
"email": "[email protected]",

src/lib/validators/openApiDiff.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ const updateChangeProperties = (change: ChangeProperties, pf: ProcessedFile): Ch
8282
}
8383
}
8484

85+
function escape(filePath: string) {
86+
return `"${filePath}"`
87+
}
88+
8589
/**
8690
* @class
8791
* Open API Diff class.
@@ -154,7 +158,7 @@ export class OpenApiDiff {
154158
const result = path.join(__dirname, "..", "..", "..", "node_modules", "autorest", "dist", "app.js")
155159
if (fs.existsSync(result)) {
156160
log.silly(`Found autoRest:${result} `)
157-
return `node ${result}`
161+
return `node ${escape(result)}`
158162
}
159163
}
160164

@@ -163,7 +167,7 @@ export class OpenApiDiff {
163167
const result = path.join(__dirname, "..", "..", "..", "..", "..", "autorest", "dist", "app.js")
164168
if (fs.existsSync(result)) {
165169
log.silly(`Found autoRest:${result} `)
166-
return `node ${result}`
170+
return `node ${escape(result)}`
167171
}
168172
}
169173

@@ -172,7 +176,7 @@ export class OpenApiDiff {
172176
const result = path.resolve("node_modules/.bin/autorest")
173177
if (fs.existsSync(result)) {
174178
log.silly(`Found autoRest:${result} `)
175-
return result
179+
return escape(result)
176180
}
177181
}
178182

@@ -188,7 +192,7 @@ export class OpenApiDiff {
188192
public openApiDiffDllPath(): string {
189193
log.silly(`openApiDiffDllPath is being called`)
190194

191-
return path.join(__dirname, "..", "..", "..", "dlls", "OpenApiDiff.dll")
195+
return escape(path.join(__dirname, "..", "..", "..", "dlls", "OpenApiDiff.dll"))
192196
}
193197

194198
/**

0 commit comments

Comments
 (0)