コード例 #1
0
        public void ParseDocumentWithDifferentCultureShouldSucceed(string culture)
        {
            Thread.CurrentThread.CurrentCulture   = new CultureInfo(culture);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);

            var openApiDoc = new OpenApiStringReader().Read(
                @"
swagger: 2.0
info: 
  title: Simple Document
  version: 0.9.1
  x-extension: 2.335
definitions:
  sampleSchema:
    type: object
    properties:
      sampleProperty:
        type: double
        minimum: 100.54
        maximum: 60,000,000.35
        exclusiveMaximum: true
        exclusiveMinimum: false
paths: {}",
                out var context);

            openApiDoc.ShouldBeEquivalentTo(
                new OpenApiDocument
            {
                Info = new OpenApiInfo
                {
                    Title      = "Simple Document",
                    Version    = "0.9.1",
                    Extensions =
                    {
                        ["x-extension"] = new OpenApiDouble(2.335)
                    }
                },
                Components = new OpenApiComponents()
                {
                    Schemas =
                    {
                        ["sampleSchema"] = new OpenApiSchema()
                                {
                                Type       = "object",
                                Properties =
                                {
                                ["sampleProperty"] = new OpenApiSchema()
                                {
                                Type             = "double",
                                Minimum          = (decimal)100.54,
                                Maximum          = (decimal)60000000.35,
                                ExclusiveMaximum = true,
                                ExclusiveMinimum = false
                                }
                                },
                                Reference = new OpenApiReference()
                                {
                                Id   = "sampleSchema",
                                Type = ReferenceType.Schema
                                }
                                }
                    }
                },
                Paths = new OpenApiPaths()
            });

            context.ShouldBeEquivalentTo(
                new OpenApiDiagnostic()
            {
                SpecificationVersion = OpenApiSpecVersion.OpenApi2_0
            });
        }