Skip to content

fix adding enum value & command line exception #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ public void CommonParameterWithRef()
public void XmsEnumModelAsString()
{
var messages = CompareSwagger("enum_as_string.json").ToArray();
Assert.Empty(messages.Where(m => m.Id == ComparisonMessages.AddedEnumValue.Id));
Assert.Equal(2,messages.Where(m => m.Id == ComparisonMessages.AddedEnumValue.Id).ToList().Count());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ private void CompareEnums(ComparisonContext<ServiceDefinition> context, T prior)
CompareXmsEnum(context,prior);
bool relaxes = (prior.Enum != null && this.Enum == null);
bool constrains = (prior.Enum == null && this.Enum != null);
bool isEnumModelAsString = (this.XmsEnum != null && this.XmsEnum.ModelAsString == true);
if (!relaxes && !constrains)
{
// It was enum and it is still enum i.e check for addition/removal
Expand All @@ -213,9 +212,7 @@ private void CompareEnums(ComparisonContext<ServiceDefinition> context, T prior)
IEnumerable<string> addedEnums = this.Enum.Except(prior.Enum);
if (addedEnums.Any())
{
if (!isEnumModelAsString) {
context.LogBreakingChange(ComparisonMessages.AddedEnumValue, String.Join(", ", addedEnums.ToList()));
}
context.LogBreakingChange(ComparisonMessages.AddedEnumValue, String.Join(", ", addedEnums.ToList()));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/oad",
"version": "0.10.2",
"version": "0.10.3",
"author": {
"name": "Microsoft Corporation",
"email": "[email protected]",
Expand Down
12 changes: 8 additions & 4 deletions src/lib/validators/openApiDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const updateChangeProperties = (change: ChangeProperties, pf: ProcessedFile): Ch
}
}

function escape(filePath: string) {
return `"${filePath}"`;
}

/**
* @class
* Open API Diff class.
Expand Down Expand Up @@ -154,7 +158,7 @@ export class OpenApiDiff {
const result = path.join(__dirname, "..", "..", "..", "node_modules", "autorest", "dist", "app.js")
if (fs.existsSync(result)) {
log.silly(`Found autoRest:${result} `)
return `node ${result}`
return `node ${escape(result)}`
}
}

Expand All @@ -163,7 +167,7 @@ export class OpenApiDiff {
const result = path.join(__dirname, "..", "..", "..", "..", "..", "autorest", "dist", "app.js")
if (fs.existsSync(result)) {
log.silly(`Found autoRest:${result} `)
return `node ${result}`
return `node ${escape(result)}`
}
}

Expand All @@ -172,7 +176,7 @@ export class OpenApiDiff {
const result = path.resolve("node_modules/.bin/autorest")
if (fs.existsSync(result)) {
log.silly(`Found autoRest:${result} `)
return result
return escape(result)
}
}

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

return path.join(__dirname, "..", "..", "..", "dlls", "OpenApiDiff.dll")
return escape(path.join(__dirname, "..", "..", "..", "dlls", "OpenApiDiff.dll"))
}

/**
Expand Down