Giter Site home page Giter Site logo

azure-functions-extensions-swashbuckle's Introduction

azure-functions-extensions-swashbuckle

Swagger tooling for API's built with Azure Functions.

This product aims to easily provide Swagger and Swagger UI of APIs created in Azure Functions using Swashbuckle.AspNetCore.

Sample

https://github.com/yuka1984/azure-functions-extensions-swashbuckle/tree/master/sample

Update

Version 1.4.4

bug fix

#20

#13

breaking changes

#9

QueryStringParamaterAttribute -> QueryStringParameterAttribute

features

#18

Thank you @LockTar

Getting Started

  1. Install the standard Nuget package into your Azure Functions application.
Package Manager : Install-Package AzureFunctions.Extensions.Swashbuckle
CLI : dotnet add package AzureFunctions.Extensions.Swashbuckle
  1. Add startup class on your Functions project.
[assembly: WebJobsStartup(typeof(SwashBuckleStartup))]
namespace YourAppNamespace
{
    internal class SwashBuckleStartup : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
            //Register the extension
            builder.AddSwashBuckle(Assembly.GetExecutingAssembly());

        }
    }
}
  1. Add swagger and swagger ui endpoint functions on your project.
public static class SwaggerController
{
    [SwaggerIgnore]
    [FunctionName("Swagger")]
    public static Task<HttpResponseMessage> Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", Route = "Swagger/json")] HttpRequestMessage req,
        [SwashBuckleClient]ISwashBuckleClient swashBuckleClient)
    {
        return Task.FromResult(swashBuckleClient.CreateSwaggerDocumentResponse(req));
    }

    [SwaggerIgnore]
    [FunctionName("SwaggerUi")]
    public static Task<HttpResponseMessage> Run2(
        [HttpTrigger(AuthorizationLevel.Function, "get", Route = "Swagger/ui")] HttpRequestMessage req,
        [SwashBuckleClient]ISwashBuckleClient swashBuckleClient)
    {
        return Task.FromResult(swashBuckleClient.CreateSwaggerUIResponse(req, "swagger/json"));
    }
}
  1. Open Swagger UI URL in your browser.

If you does not changed api route prefix. Swagger UI URL is https://hostname/api/swagger/ui .

Options

Include Xml document file

AzureFunctions.Extensions.Swashbuckle can include xml document file.

  1. Change your functions project's GenerateDocumentationFile option to enable.

  2. Add configration setting this extensions on your functions project's hots.json

{
  "version": "2.0",
  "extensions": {
    "Swashbuckle": {
      "XmlPath":  "{your document xml file name}" 
    } 
  }
}

azure-functions-extensions-swashbuckle's People

Contributors

locktar avatar yuka-abn avatar yuka1984 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

azure-functions-extensions-swashbuckle's Issues

Can I overwrite function name for the swagger ui?

Hi.
I have a question about if I can overwrite the function name to add '/' separator. By default the extension take the function name as the title.

I tried to change the code but it won't allow me that function name with '/'. I want the function route as the title.

image

JsonProperty doesn't apply

Hi,

my model has a property I wanted to rename for serialization. I tried JsonProperty and DataMember but swagger will not get updated. When I change property name it updates.

My startup inherits from FunctionsStartup and setup looks like this:

builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
            {
                opts.SpecVersion = OpenApiSpecVersion.OpenApi3_0;
                opts.AddCodeParameter = true;
                opts.PrependOperationWithRoutePrefix = true;
                opts.Documents = new[]
                {
                    new SwaggerDocument
                    {
                        Name = "v1",
                        Title = "Title",
                        Description = "Azure functions",
                        Version = "v2"
                    }
                };
                opts.Title = "Firma Prehledne - Reporting";
                opts.ConfigureSwaggerGen = (x =>
                {
                    x.EnableAnnotations();
                });
            });

I have tried also SecVersion = 2.0

Thanks

Support for .NET Core v3

I want to use this package. But when i tried to use it on my project (which use .NET Core v3) it doesn't work, it gives error:
Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
it still work perfectly tho if i don't use any annotations in my model.

Validation is not fired

Hi,

I have used Required attribute, Email validation attribute, marked disable null for property but no error gets fired with RequestBodyType.

What should I do?

Thanks

How to enable file upload in swagger using Swashbuckle

Hi,

I'm using swashbuckle to get swagger for my azure functions . These functions have file upload functionalities and I couldn't get swagger to accept file objects for them. By default, it is only accepting application/json content type but not "multipart/form-data". Any help would be great

Thank you

Group functions in SwaggerUI

Hi yuka1984,
in my current function implementations every method has its own headline in the ui.
Is it possible to group the function methods e.g. by class or by a custom name?
Current:
image
Idea (Tags Attribute?):
image

Kind regards

Azure API Mgnt Integration

Is there a way to generate the code so it will ignore the "Code" field? We are exposing the APIs thru Azure API Mgnt and it automatically passes the code behind the scenes, but Im using the swagger json URL in the UI to create the endpoints in the API Mgnt and it says "Code" is required because the auth level is "Function" which is correct, we dont want it to be "anon". I would need to go thru and edit all the imported configs to remove it.

REF:
image

"/api/GetAnswers": {
      "post": {
        "tags": [
          "GetAnswers"
        ],
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GetAnswersInputDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GetAnswersResponseDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Void"
                }
              }
            }
          }
        }
      }

Support Required Attribute

Items are optional by default if they are query String parameters or when there is a question mark (?) in the URL parameter... But When you use custom binding to add your model in the method it appears as a body parameter that is optional, but of course, this is required (in many cases I presume) so it would be great if the Required attribute could be read here to make a parameter required... But the same goes for query parameters I guess.

Of course, it also needs to be used here too:

So that it can be rendered as required (not optional)

Adding Swagger to FunctionsAppStartup

Hi,

I'm trying to add swagger to my Azure Functions 2.0 app which is using dependency injection using the FunctionsStartup attribute. Most of the documentation below is suggesting that I need to use a startup class using the WebJobsStartup attribute.

Could you please let me know if this is possible?

Thanks

Enhancement - Update StatupConfig to accept SwaggerGenOptions object

I actually already have a pull on the code that does this if you want, but one of the things I noticed is that if you want to add your own operation filters you can't so I made it so you can inject your own SwaggerGenOptions object into the extension so that it will automatically copy them over into the swagger config in the service colelction. Let me know if you want me to send you the updated project.

Modify Swagger UI Title, Description and Version.

Hi,

I am using this package to display Swagger UI but I don't want predefined Title, Description and Version on UI.
Can you please suggest, how can I modify below information in my Azure Function-2 application?

Kindly see attached screen shots. I have also attached one screen-shot highlighting the configuration I have done.

Swag1
Swag2

Including swagger in a V3 function with "FunctionsStartup"

Hi,
I have an Azure function (V3) and, for DI, I would like to use the FunctionsStartup rather than implementing IWebJobsStartup. When I implement IWebJobsStartup this works but not when I inherit from FunctionsStartup. I am pretty sure that, I am doing something fundamentally wrong here, but almost all of the search results lead to a solution which implements IWebJobsStartup directly.

Below is the error which I get. Any help is highly appreciated!

Microsoft.Azure.WebJobs.Host: Error indexing method 'Swagger'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), build
er.AddTimers(), etc.).

My startup class is as below,

    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var services = builder.Services;
            RegisterSwaggerDocumentation(services);
        }

        private void RegisterSwaggerDocumentation(IServiceCollection services)
        {
            if (services == null)
            {
                return;
            }

            services.AddSwaggerGen();

            //services.AddSwaggerGen(options =>
            //{
            //    options.SwaggerGeneratorOptions = new SwaggerGeneratorOptions
            //    {
            //        DescribeAllParametersInCamelCase = true
            //    };
            //});
        }
    }

The function I am testing is this,

    public class GetTodoFunction
    {
        private readonly ILogger<GetTodoFunction> _logger;

        public GetTodoFunction(ILogger<GetTodoFunction> logger)
        {
            _logger = logger;
        }

        [FunctionName(nameof(GetTodoFunction))]
        public async Task<IActionResult> GetTodoAsync([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todos/{id}")]
            HttpRequest request, string id)
        {
            _logger.LogInformation($"{nameof(GetTodoFunction)} started.");

            await Task.Delay(TimeSpan.FromSeconds(1));
            
            return new OkObjectResult($"{id}");
        }
    }

The swagger functions are,

    public class SwaggerDocumentFunction
    {
        [SwaggerIgnore]
        [FunctionName("Swagger")]
        public Task<HttpResponseMessage> GenerateDocumentAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "swagger/json")] HttpRequestMessage request,
            [SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
        {
            return Task.FromResult(swashBuckleClient.CreateSwaggerDocumentResponse(request));
        }

        [SwaggerIgnore]
        [FunctionName("SwaggerUI")]
        public Task<HttpResponseMessage> GenerateUserInterfaceAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "swagger/ui")] HttpRequestMessage request,
            [SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
        {
            return Task.FromResult(swashBuckleClient.CreateSwaggerUIResponse(request, "swagger/json"));
        }
    }

QueryStringParameter is Mispelled and also breaks the swagger definition

First off I wanted to say how thankful I am you are working on this. I was able to get up and running quite easily and everything seems to be working well. However, I have noticed some issues.
First: 'QueryStringParamater' is mis-spelled and should be 'QueryStringParameter'
Second: When I use it it breaks my swagger definition.

To reproduce just add an annotation like '[QueryStringParamater("jobId", "Id of Job you are deleting.", Required = true)]' to a function then the azure logs give:
'[7/11/2019 8:42:58 PM] Executed 'Swagger' (Failed, Id=10b20162-2910-43b3-a9cb-4f99db00efe9)
[7/11/2019 8:42:58 PM] System.Private.CoreLib: Exception while executing function: Swagger. Swashbuckle.AspNetCore.SwaggerGen: Object reference not set to an instance of an
object.'

And the swagger UI endpoint yields: 'No API definition provided.'

Once this is fixed an available on Nuget I would happily start using this in my azure function projects. Thanks for you work!

Configure Openapi 2

Swashbuckle allows us to generate both openapi 2 and 3 docs. Is there a way of generating openapi 2? Example code on Swashbuckle docs:

app.UseSwagger(c =>
{
    c.SerializeAsV2 = true;
});

TIA

Does not work with Functions v3

I get the following error.

A host error has occurred during startup operation 'a9f43d8a-89ae-4480-8c8f-9b6b8ad75098'. [5.12.2019 14:46:13] AzureFunctions.Extensions.Swashbuckle: Could not load type 'Microsoft.AspNetCore.Mvc.Internal.DefaultValidationMetadataProvider' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

[JsonConverter(typeof(StringEnumConverter))] Does not work for RequestBodyType Params request

Trying to use request body type and to see enum string value instead of int.
Seems to be not working.

 public async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "func1")] 
            [RequestBodyType(typeof(MyConfiguration), "Params request")]
            HttpRequest req,
            ILogger log)
        {

  public class MyConfiguration
    {
        public TargetType TargetType { get; set; }
....

  [JsonConverter(typeof(StringEnumConverter))]
    public enum TargetType
    {

Failed to load API definition

I created a simple project where I added the latest version of the extension. I get this error:

image

Failed to load API definition
Fetch error
Unauthorized

I put my code here. I followed the steps in the project page. It was working perfectly on Azure until a couple of day ago. Locally is working.

{
  "schemaValidationMessages": [
    {
      "level": "error",
      "message": "Can't read from file https://azuks-test-q001.azurewebsites.net/api/swagger/json"
    }
  ]
}

Update

For same reason, the code param can't be the same for json and UI. If you open your Swagger url with Get Function url and copy the url from UI function, it is working.

image

Swagger security flaw

AuthorizationLevel defined as Function. i.e. The caller have to specify key in the request otherwise caller will receive a 401 Unauthorized..

But how come when I click "Execute" in Swagger UI, it is successfully calling the function.
Isn't this is a security flaw? i.e. if I host my Function app with this Swagger, anyone in could potentially call it successfully?

The sample won't work

The sample won't work due to the following code never called. if I move the startup code to separate lib, the startup code is called but the UI/JSON page showing empty.

public void Configure(IWebJobsBuilder builder)
{
//Register the extension
builder.AddSwashBuckle(Assembly.GetExecutingAssembly());

    }

The startup code is not running so that's why
Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding

Swagger UI on https with SSL offloading errors because of json url then uses http

I'm using @vitalybibikov fork (nuget: https://www.nuget.org/packages/AzureExtensions.Swashbuckle/) which is working great for me with Azure Functions v3.1 - but one issue in that I force https and the swagger ui is great but the json explore url defaults to http only, which errors as I don't allow non-https.

SwaggerUI_JsonUrlIssue

[Posting here as @vitalybibikov fork doesn't have issues enabled]

I'm not sure if this happens on this code base too but just wondering if anyone has seen this or better still solved it?

Issues with Swashbuckle v5.5.1

'Could not load type 'Swashbuckle.AspNetCore.Swagger.SwaggerDocument' from assembly 'Swashbuckle.AspNetCore.Swagger, Version=5.5.1.0, Culture=neutral, PublicKeyToken=62657d7474907593'.'

Invalid OperationIds Error

Hi,
i ran into an invalid swagger documentation with the following setup:
Installed nuget in version 1.4.1 and specified multiple methods (get and post) in a http triggered function. I added a screenshot of the function:
image

The generated definition now contains two operation ids with the same name ("Run"):
[…]
/api/test:
get:
tags:
- TestFunction
operationId: Run
consumes: []
produces: []
parameters: []
responses:
'200':
description: Success
post:
tags:
- TestFunction
operationId: Run
consumes: []
produces: []
parameters: []
responses:
'200':
description: Success
[…]

Swagger Online Validator Error Message:
{"messages":["attribute paths.'/api/test'(get).operationId is repeated","attribute paths.'/api/test'(post).operationId is repeated"]}

Swagger Editor Error Message:
Semantic error at paths./api/test.get.operationId
Operations must have unique operationIds.
Jump to line 28
Semantic error at paths./api/test.post.operationId
Operations must have unique operationIds.
Jump to line 38

Kind Regards

Swagger with no Authorization

[FunctionName("Swagger")] and [FunctionName("SwaggerUi")] is defined as AuthorizationLevel.Function. This means you can't access swagger without passing ?code=<<_master key here>>.

For example, I can only see swagger if I follow following steps:

  1. Goto https://<APP_NAME>.azurewebsites.net/api/swagger/ui?code=<API_KEY>
  2. UI opens, but can't see anything. It throw 401 Unauthorized
  3. Then in the textbox above, I need to change it to https://<APP_NAME>.azurewebsites.net/api/swagger/json?code=<API_KEY>
  4. and on click of Explore I see my swagger UI.
  5. How can we avoid authorization to open Swagger UI, but still keep Function Secure.

Customize Swagger page with Azure Functions v. 3

Great job! I'm using your extension with Azure Functions v. 3 and I don't face any issue.

image

I want to customize the Swagger page, for example the title. I read a post where it explains how to add some configuration but it doesn't work for me.

Basically, I added some json in the host.json

{
  "version": "2.0",
  "extensions": {
    ...
 
    "Swashbuckle": {
      "Documents": [
        {
          "Title": "YOUR_TITLE",
          "Version": "v1",
          "Description": "YOUR_DESCRIPTION"
        }
      ]
    }
  }
}

What is the right think to do? Thank you!

How to describe url query parameters

For example if the GetItems had two url query parameters "code" and "category"
Is it possible to set this up so the query parameters can be visible in swagger ui?

Thanks

How To - Request Parameters

Edit: I figured it out! If you're not interested in the problem see below for the answer.

Hello,

I've been trying to figure this out and I'm sure I've missed something simple. If anyone here could point me in the right direct I'd be very grateful.

I have an Azure Function v3 project built that implements nuget packages from this fork. My csproj is generating the XML doc and Swagger Gen/UI seems to be reading the function summaries. Just for clarity my hosts.json file looks like this...

// removed for brevity //
"Swashbuckle": {
    "XmlPath": "Functions.xml"
}

My problem is XML parameter properties like <param name="Id">Id of menu</param> are not reflected in the Swagger UI as input parameters. The only input parameter I have 'code' which I believe is the function specific API key. I am just trying to get the function input parameters into my Swagger doc.

Does anyone have this working and, if so, can you provide an example? I have tried various settings adjustments and looking through this repo's issues. I also removed my XML configuration and confirmed that all of my summaries / etc went away.

Previously I've implemented this in asp.net core api projects and it always picks up the method model properties as inputs with little issue. In functions the entire request is passed in so I though I would use <param>.

Thanks,
Kevin

dotnet core v3.1 | Request Body is Blank (even in sample Product Controller test)

Hello!

Thanks for the great package. Thanks to some of the other issues and solutions provided by other contributors I have been able to install AzureFunctions.Extensions.Swashbuckle.Attribute in my dotnet core v3.1 Azure Function project.


I have a few bugs I am working out with this. The main one I would like to post about because its pretty impactful is that the

RequestBody

is missing from the Swagger documentation. I also tested this using the test code provided and was able to reproduce.

(Note: in dotnet core v3.1 I recieved an error leaving 'post', 'product' in the HttpTrigger Annotation. To get it to build I had to remove the 'product' string. I will circle it in my code.)
image

image


Any idea what could be creating the issue?

Getting attached error. Project file is mentioned as well

netcoreapp3.1 v3 PreserveNewest PreserveNewest Never

[08-04-2020 12:23:18] Microsoft.Azure.WebJobs.Host: Error indexing method 'Swagger'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[08-04-2020 12:23:18] Error indexing method 'Swagger'
[08-04-2020 12:23:18] Microsoft.Azure.WebJobs.Host: Error indexing method 'Swagger'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[08-04-2020 12:23:18] Function 'Swagger' failed indexing and will be disabled.
[08-04-2020 12:23:19] Microsoft.Azure.WebJobs.Host: Error indexing method 'SwaggerUi'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[08-04-2020 12:23:19] Error indexing method 'SwaggerUi'
[08-04-2020 12:23:19] Microsoft.Azure.WebJobs.Host: Error indexing method 'SwaggerUi'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[08-04-2020 12:23:19] Function 'SwaggerUi' failed indexing and will be disabled.
[08-04-2020 12:23:19] Found the following functions:
[08-04-2020 12:23:19] BiotiaCovidDALFunc.BiotiaCovidDALFunc.InsertFile
[08-04-2020 12:23:19] BiotiaCovidDALFunc.BiotiaCovidDALFunc.InsertPipelineStatus
[08-04-2020 12:23:19]
[08-04-2020 12:23:19] Initializing function HTTP routes
[08-04-2020 12:23:19] Mapped function route 'api/InsertFile' [get,post] to 'InsertFile'
[08-04-2020 12:23:19] Mapped function route 'api/InsertPipelineStatus' [get,post] to 'InsertPipelineStatus'
[08-04-2020 12:23:19] Mapped function route 'api/swagger/json' [get] to 'Swagger'
[08-04-2020 12:23:19] Mapped function route 'api/swagger/ui' [get] to 'SwaggerUi'
[08-04-2020 12:23:19]
[08-04-2020 12:23:19] Host initialized (641ms)
[08-04-2020 12:23:19] Host started (668ms)
[08-04-2020 12:23:19] Job host started
[08-04-2020 12:23:19] The 'Swagger' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Swagger'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[08-04-2020 12:23:19] The 'SwaggerUi' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'SwaggerUi'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

Add support for Examples

Hi,

the library Swashbuckle.AspNetCore.Filters and interface IExamplesProvider witth attribute SwaggerRequestExample will not apply to swagger

Thanks

Azure API Management

Does anyone use this with Azure API Management?
It seems like their "portal" screen doesnt render "objects" defined in schemes.
EX:
image

vs

image

Request header parameters not being sent

Hi Yuka,

I could able to successfully configure Swagger ui for my Azure functions. However, I am facing weird issue header parameter(Authentication) value not being sent due to this I am getting 401 response.

Please find below json for reference
{
"openapi": "3.0.1",
"info": {
"title": "Sample Azure Services",
"description": "Azure functions",
"version": "v1"
},
"servers": [
{
"url": ""
}
],
"paths": {
"/SampleService": {
"post": {
"tags": [
"SampleService"
],
"summary": "",
"parameters": [
{
"name": "Authorization",
"in": "header",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SampleServiceModel"
}
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FIleModel"
}
}
}
}
}
}
}
}
}

My function header:
[FunctionName("SampleService")]
[ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)]
[Produces("application/json")]
[RequestHttpHeader("Authorization", isRequired: true)]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] [RequestBodyType(typeof(SampleServiceModel[]), "Sample Service request")] HttpRequest req,
ILogger log)
{
}

CURL:
curl -X POST "" -H "accept: text/plain" -H "Content-Type: application/json" -d "{"input":"string","output":"string","searchFor":"string","replaceWith":"string","searchDirection":"Forward","searchType":"sample","distance":0,"actionType":"actiontype"}"

Can you please help me to resolve issue?

Generated XML Documentation File Not Working

Anyone else having issues with XML Documentation? The feature seems not to be working.
Azure Functions unable to locate XML file...

{
"version": "2.0",
"extensions": {
"Swashbuckle": {
"XmlPath": "Func.xml"
}
}
}

Missing port in local tests

Hi,
in version 1.4.2 the try out button doesnt work anymore.
In the base uri, that is shown in the ui, the port is missing and it calls "localhost" without the port.
The swagger json file is loaded correctly with port.
e.g. http://localhost:7071

Kind regards

Feature Request - InjectStylesheet

Hi yuka1984,
i remember from the other Swashbuckle implementations that it was possible to inject a custom css.
It was possible with that definitions to change the color and the icon on the ui for example.
Is there a plan to implement some feature like that?
Kind regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.