Exemplo n.º 1
0
        /// <summary>Adds a document to the registry.</summary>
        /// <param name="documentName">The document name.</param>
        /// <param name="swaggerGenerator">The Swagger generator.</param>
        /// <returns>The registry.</returns>
        public SwaggerDocumentRegistry AddDocument(string documentName, ISwaggerGenerator swaggerGenerator)
        {
            if (_documents.ContainsKey(documentName))
            {
                throw new ArgumentException("The OpenAPI/Swagger document '" + documentName + "' is already registered: " +
                                            "Explicitely set the DocumentName property in " +
                                            nameof(NSwagServiceCollectionExtensions.AddSwaggerDocument) + "() or " +
                                            nameof(NSwagServiceCollectionExtensions.AddOpenApiDocument) + "().");
            }

            _documents[documentName] = swaggerGenerator;
            return(this);
        }
Exemplo n.º 2
0
        private void LoadGeneratoers(NSwagDocument document)
        {
            SwaggerGenerators = new ISwaggerGenerator[]
            {
                new SwaggerInputGeneratorView(Document),
                new WebApiSwaggerGeneratorView(Document.WebApiToSwaggerCommand),
                new JsonSchemaInputGeneratorView(Document),
                new AssemblySwaggerGeneratorView(Document.AssemblyTypeToSwaggerCommand),
            };

            ClientGenerators = new IClientGenerator[]
            {
                new SwaggerGeneratorView(),
                new TypeScriptCodeGeneratorView(Document.SwaggerToTypeScriptCommand),
                new CSharpClientGeneratorView(Document.SwaggerToCSharpCommand)
            };

            RaisePropertyChanged(() => SwaggerGenerators);
            RaisePropertyChanged(() => ClientGenerators);
        }               
Exemplo n.º 3
0
        private void LoadGeneratoers(NSwagDocument document)
        {
            SwaggerGenerators = new ISwaggerGenerator[]
            {
                new SwaggerInputGeneratorView(Document),
                new WebApiSwaggerGeneratorView(Document.WebApiToSwaggerCommand),
                new JsonSchemaInputGeneratorView(Document),
                new AssemblySwaggerGeneratorView(Document.AssemblyTypeToSwaggerCommand),
            };

            ClientGenerators = new IClientGenerator[]
            {
                new SwaggerGeneratorView(),
                new TypeScriptCodeGeneratorView(Document.SwaggerToTypeScriptCommand),
                new CSharpClientGeneratorView(Document.SwaggerToCSharpCommand)
            };

            RaisePropertyChanged(() => SwaggerGenerators);
            RaisePropertyChanged(() => ClientGenerators);
        }
Exemplo n.º 4
0
 /// <summary>Initializes a new instance of the <see cref="SwaggerDocumentRegistration"/> class.</summary>
 /// <param name="documentName">The document name.</param>
 /// <param name="generator">The document generator.</param>
 public SwaggerDocumentRegistration(string documentName, ISwaggerGenerator generator)
 {
     DocumentName = documentName;
     Generator    = generator;
 }
 public GenerateSwagger(ISwaggerGenerator swaggerGenerator)
 {
     this.swaggerGenerator = swaggerGenerator;
 }
Exemplo n.º 6
0
 public SwaggerEndpoint(ISwaggerGenerator swaggerGenerator)
 {
     this.swaggerGenerator = swaggerGenerator;
 }