-
Notifications
You must be signed in to change notification settings - Fork 280
Closed
Labels
type:bugA broken experienceA broken experience
Description
Symptom - Read definition in some culture settings will fail
When using OpenApiStringReader.Read to read PetStore example, i got a "System.FormatException".
My operating system is in English, but the Currency and DateTime formats are set to "fr-FR".
I doubt that the conversion failed because in French the decimal separator is comma , but not a point .
Actually i got a workaround that to change the CurrentCulture and CurrentUICulture of the current Thread to "en-us" before read the document, then set them back after document has been read.
For example
CultureInfo ci = new CultureInfo("en-us");
CultureInfo.DefaultThreadCurrentCulture = ci;
CultureInfo.DefaultThreadCurrentUICulture = ci;If you set CultureInfo to "fr-FR", you can reproduce the FormatException.
I have no control on the users culture settings, so I will use this workaround for instance.
Will there be a fix for this ?
Stack Trace of the Exception
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__72_92(OpenApiParameter o, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap, List`1 requiredFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadParameter(ParseNode node, Boolean evenBody)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadParameter(ParseNode node)
at Microsoft.OpenApi.Readers.ParseNodes.ListNode.<>c__DisplayClass2_0`1.<CreateList>b__0(YamlNode n)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.OpenApi.Readers.ParseNodes.ListNode.CreateList[T](Func`2 map)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__72_65(OpenApiOperation o, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap, List`1 requiredFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadOperation(ParseNode node)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__72_103(OpenApiPathItem o, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap, List`1 requiredFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadPathItem(ParseNode node)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__72_114(OpenApiPaths o, String k, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap, List`1 requiredFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadPaths(ParseNode node)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.<>c.<.cctor>b__72_12(OpenApiDocument o, ParseNode n)
at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap, List`1 requiredFields)
at Microsoft.OpenApi.Readers.V2.OpenApiV2Deserializer.LoadOpenApi(RootNode rootNode)
at Microsoft.OpenApi.Readers.V2.OpenApiV2VersionService.LoadDocument(RootNode rootNode)
at Microsoft.OpenApi.Readers.ParsingContext.Parse(YamlDocument yamlDocument, OpenApiDiagnostic diagnostic)
at Microsoft.OpenApi.Readers.OpenApiStreamReader.Read(Stream input, OpenApiDiagnostic& diagnostic)
at Microsoft.OpenApi.Readers.OpenApiStringReader.Read(String input, OpenApiDiagnostic& diagnostic)Metadata
Metadata
Assignees
Labels
type:bugA broken experienceA broken experience