Exemplo n.º 1
0
        public void TestInitialise()
        {
            _typeParser = new Mock <IOpenApiSpecUmbrellaTypeParser <JsonCatchAllTypeModel> >();

            _service = new OpenApiSpecObjectParser <JsonCatchAllTypeModel>(_typeParser.Object);

            _prop1      = new JsonCatchAllTypeModel();
            _prop2      = new JsonCatchAllTypeModel();
            _extended1  = new JsonCatchAllTypeModel();
            _extended2  = new JsonCatchAllTypeModel();
            _inputModel = new JsonCatchAllTypeModel()
            {
                Properties = new Dictionary <string, JsonCatchAllTypeModel>()
                {
                    { "FirstProp", _prop1 },
                    { "SecondProp", _prop2 }
                },
                AllOf = new List <JsonCatchAllTypeModel>()
                {
                    _extended1,
                    _extended2
                }
            };

            _typeParser.Setup(s => s.Parse(_service,
                                           It.IsAny <JsonCatchAllTypeModel>()))
            .Returns(() => new OpenApiPrimitiveType());
        }
Exemplo n.º 2
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            var filePathFormatService = new FilePathFormattingService();
            var jsonTypeParser        = new OpenApiSpecUmbrellaTypeParser <JsonCatchAllTypeModel>();
            var jsonObjectParser      = new OpenApiSpecObjectParser <JsonCatchAllTypeModel>(jsonTypeParser);
            var yamlTypeParser        = new OpenApiSpecUmbrellaTypeParser <YamlCatchAllTypeModel>();
            var yamlObjectParser      = new OpenApiSpecObjectParser <YamlCatchAllTypeModel>(yamlTypeParser);
            var lastTokenService      = new LastTokenInPathService();
            var enumFromStringService = new EnumFromStringService();
            var shortNameService      = new OpenApiEndpointShortNameService(lastTokenService);

            var moduleBuilderProvider   = new ModuleBuilderProvider();
            var openApiPrimitiveService = new OpenApiPrimitiveToTypeService(new OpenApiEnumToTypeService(moduleBuilderProvider));
            var openApiTypeResolver     = new OpenApiUmbrellaTypeResolver(openApiPrimitiveService,
                                                                          new OpenApiReferenceToTypeService(lastTokenService));
            var openApiObjectToTypeService = new OpenApiObjectToTypeService(openApiTypeResolver,
                                                                            new StealFieldsFromOpenApiObjectTypeService(openApiTypeResolver),
                                                                            moduleBuilderProvider);

            //establish current ps session working directory
            using (var session = PowerShell.Create(RunspaceMode.CurrentRunspace))
            {
                session.AddCommand("get-location");
                _pwd = session.Invoke <PathInfo>()
                       .FirstOrDefault()?.Path;
            }

            _specImportService = new ImportSpecFromFilePathService(filePathFormatService,
                                                                   new JsonFileToOpenApiModelService(jsonObjectParser,
                                                                                                     jsonTypeParser,
                                                                                                     new OpenApiJsonEndpointsParser(jsonTypeParser,
                                                                                                                                    jsonObjectParser,
                                                                                                                                    enumFromStringService),
                                                                                                     shortNameService),
                                                                   new YamlFileToOpenApiModelService(yamlObjectParser,
                                                                                                     yamlTypeParser,
                                                                                                     new OpenApiYamlEndpointsParser(yamlTypeParser,
                                                                                                                                    yamlObjectParser,
                                                                                                                                    enumFromStringService),
                                                                                                     shortNameService),
                                                                   new OpenApiSpecModelToGeneratedTypesService(openApiObjectToTypeService,
                                                                                                               openApiTypeResolver,
                                                                                                               new OpenApiEndpointToEndpointService(openApiTypeResolver,
                                                                                                                                                    openApiPrimitiveService,
                                                                                                                                                    openApiObjectToTypeService)));
        }