-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from MobileTeleSystems/fix/issue6_notLoadYaml
Dont check extension for detect file format
- Loading branch information
Showing
2 changed files
with
3 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,19 +120,12 @@ protected static async Task<OpenApiDocument> ReadAndProcessOpenApiDocument(Gener | |
var documentStr = context.DocumentReader!.ReadToEnd(); | ||
documentStr = InvokePreprocessors<string>(documentStr, context.Preprocessors, context.DocumentPath); | ||
|
||
var openApiDocument = IsYaml() | ||
var openApiDocument = !(documentStr.StartsWith("{") && documentStr.EndsWith("}")) | ||
? await OpenApiYamlDocument.FromYamlAsync(documentStr) | ||
: await OpenApiDocument.FromJsonAsync(documentStr); | ||
|
||
openApiDocument = InvokePreprocessors<OpenApiDocument>(openApiDocument, context.Preprocessors, context.DocumentPath); | ||
return openApiDocument; | ||
|
||
bool IsYaml() | ||
{ | ||
return | ||
(context.DocumentPath is not null && (context.DocumentPath.EndsWith("yml") || context.DocumentPath.EndsWith("yaml"))) | ||
|| !(documentStr.StartsWith("{") && documentStr.EndsWith("}")); | ||
} | ||
} | ||
|
||
} | ||
Check warning on line 131 in src/ApiCodeGenerator.OpenApi/ContentGeneratorBase.cs GitHub Actions / build_and_test
Check warning on line 131 in src/ApiCodeGenerator.OpenApi/ContentGeneratorBase.cs GitHub Actions / build_and_test
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters