Skip to content

Commit cc6c3f0

Browse files
authored
Merge pull request #367 from ross-p-smith/ross/invalidSpec
Throw informative error if the specification file is invalid.
2 parents 1853ccc + b3b8338 commit cc6c3f0

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,7 @@ MigrationBackup/
361361
appsettings.json
362362
/tools/code/extractor/Properties/launchSettings.json
363363
/tools/code/publisher/Properties/launchSettings.json
364+
365+
# These files are your personal settings - don't commit them to source control.
366+
tools/code/.env.publisher
367+
tools/code/.env.extractor

tools/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ This option allows you to run the extractor and publisher binaries on your local
1515
az ad sp create-for-rbac --name myApp --role contributor --scopes /subscriptions/{subscription-id}/resourceGroups/exampleRG --sdk-auth
1616
```
1717
* The output is a JSON object with the role assignment credentials. Copy this JSON object for later. You'll only need the sections with the clientId, clientSecret, subscriptionId, and tenantId values.
18-
* Update the values in the `.env.extractor` file to include the information required for the extractor to run sucessfully.
19-
* Update the values in the `.env.publisher` file to include the information required for the publisher to run sucessfully
18+
* Copy and rename `./tools/code/.env.extractor.template` to `./tools/code/.env.extractor` and update the values to include the information required for the extractor to run sucessfully. This file will not be committed to source control
19+
* Copy and rename `./tools/code/.env.publisher.template` to `./tools/code/.env.publisher` and update the values to include the information required for the publisher to run sucessfully. This file will not be committed to source control
2020
* Place a breakpoint on the opened source code file
2121
* Run the "Launch Extractor" from the debugger section in VS Code to debug the extractor
2222
* Run the "Launch Publisher" from the debugger section in VS Code to debug the publisher
@@ -40,8 +40,8 @@ This option allows you to run the extractor and publisher binaries in a containe
4040
az ad sp create-for-rbac --name myApp --role contributor --scopes /subscriptions/{subscription-id}/resourceGroups/exampleRG --sdk-auth
4141
```
4242
* The output is a JSON object with the role assignment credentials. Copy this JSON object for later. You'll only need the sections with the clientId, clientSecret, subscriptionId, and tenantId values.
43-
* Update the values in the `.env.extractor` file to include the information required for the extractor to run sucessfully.
44-
* Update the values in the `.env.publisher` file to include the information required for the publisher to run sucessfully
43+
* Copy and rename `./tools/code/.env.extractor.template` to `./tools/code/.env.extractor` and update the values to include the information required for the extractor to run sucessfully. This file will not be committed to source control
44+
* Copy and rename `./tools/code/.env.publisher.template` to `./tools/code/.env.publisher` and update the values to include the information required for the publisher to run sucessfully. This file will not be committed to source control
4545
* Place a breakpoint on the opened source code file
4646
* Run the "Launch Extractor" from the debugger section in VS Code (remember that Github Codespaces runs VS Code in the browser) to debug the extractor
4747
* Run the "Launch Publisher" from the debugger section in VS Code (remember that Github Codespaces runs VS Code in the browser) to debug the publisher
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#Extractor environment variables
1+
# Extractor environment variables
2+
## Please make a copy of this and rename it to `.env.extractor`
23
AZURE_RESOURCE_GROUP_NAME=<source apim instance resource group>
34
API_MANAGEMENT_SERVICE_NAME=<source apim instance name>
45
AZURE_CLIENT_ID=<AZURE_CLIENT_ID>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#Publisher environment variables
1+
# Publisher environment variables
2+
## Please make a copy of this and rename it to `.env.publisher`
23
AZURE_RESOURCE_GROUP_NAME=<destination apim instance resource group>
34
AZURE_CLIENT_ID=<AZURE_CLIENT_ID>
45
AZURE_CLIENT_SECRET=<AZURE_CLIENT_SECRET>

tools/code/publisher/Api.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ private static async ValueTask<string> GetOpenApiV3SpecificationText(ApiSpecific
352352
{
353353
using var fileStream = openApiSpecificationFile.ReadAsStream();
354354
var readResult = await new OpenApiStreamReader().ReadAsync(fileStream);
355+
if (readResult.OpenApiDiagnostic.Errors.Any())
356+
{
357+
throw new IOException($"Could not read OpenAPI specification file {openApiSpecificationFile.Path}.");
358+
}
355359
return readResult.OpenApiDocument.Serialize(openApiSpecificationFile.Version, openApiSpecificationFile.Format);
356360
}
357361

0 commit comments

Comments
 (0)