Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:35
    RicoSuter edited #3349
  • 18:18
    erwinkramer edited #3349
  • 18:18
    erwinkramer edited #3349
  • 18:12
    RicoSuter labeled #3344
  • 18:12
    RicoSuter labeled #3344
  • 18:12
    RicoSuter labeled #3347
  • 18:12
    RicoSuter labeled #3347
  • 18:12
    RicoSuter commented #3347
  • 17:55
    erwinkramer edited #3349
  • 17:54
    erwinkramer opened #3349
  • 17:41
    dependabot[bot] labeled #3348
  • 17:41

    dependabot[bot] on npm_and_yarn

    Bump elliptic from 6.5.3 to 6.5… (compare)

  • 17:41
    dependabot[bot] opened #3348
  • 17:20
    codingdna2 commented #3205
  • 16:59
    0xorial opened #3347
  • 16:58
    jeremyVignelles commented #3343
  • 16:50
    RicoSuter labeled #3342
  • 16:50
    RicoSuter labeled #3342
  • 16:50
    RicoSuter labeled #3342
  • 16:49
    RicoSuter commented #3343
Jérémy VIGNELLES
@jeremyVignelles
I usually don't put the property name as nullable anymore, I use "" instead
IIRC, it works well
Rico Suter
@RicoSuter
.. i think if we return "" and never null in ConvertToString it might be fine. But we'd need to check the ConvertToString usages, but it looks fine
Jérémy VIGNELLES
@jeremyVignelles
will do
agono
@agono
hi! how exactly can i use my own liquid template? i'am using NSwag studio to generate POCOs (for client) and everything works fine except Dates which are send by the service (not my service) in Unix epoch format in milliseconds. I found this on SO, but what i cannot find anywhere is where to put my custom templates: https://stackoverflow.com/questions/54094085/nswagstudio-liquid-templates
Jérémy VIGNELLES
@jeremyVignelles
@agono isn't there a TemplateDirectory setting?
aktxyz
@aktxyz
is it possible to tell swagger to ignore some routes ... I have a case where the same controller+method has multiple routes (legacy reasons to make same api have 2 names) ... but want one of the routes ignored when creating the swagger doc
Rico Suter
@RicoSuter
[OpenApiIgnore] attribute
aktxyz
@aktxyz
hmm ... I thought that only ignore methods ... but just tried and it looks like it ignores routes too ! thanks
Jérémy VIGNELLES
@jeremyVignelles
Toshko Andreev
@Ravenheart
hello
is there a way to generate a client that will do Xml requests
currently the generated models are sprinkled for Json serialization
but the service i'll be calling only supports Xml
Jon Reginbald Ivarsson
@reginbald
Hi, Is it possible to set a routePrefix so that swagger ui will be served from www.example.com ?
Rico Suter
@RicoSuter
@Ravenheart I think this is currently not possible (ie the xml serializer is not implemented) - there is an issue for that somewhere :-)
@reginbald did you try?
app.UseSwaggerUi3(p => p.Path = "/")
Jérémy VIGNELLES
@jeremyVignelles
Just wondering : What happens in NSwag when both "Default" response type and "success" (200) response type are set ? They can't both return, right ?
Jason Delladecimas
@JDelladecimas
Hi all, I have a .Net Core 3.1 project and I'm using NSwag with MSBuild to generate an angular client. The output is a single file with a module and all the C# controllers as services in it. Is there a way to split each service and module into separate files? This my first post so apologies if this is the wrong platform. Great product btw - saves a lot of dev time.
Jérémy VIGNELLES
@jeremyVignelles
@JDelladecimas : No, there isn't
Hobbes Pirakitti
@hobbes-visionfriendly-com
Hi! Quick question (I hope). I am using WebAPI / OWIN. I have a controller action that is [HttpGet] and takes a single parameter that is a "complex" type. That is, they argument to the parameter is a class that has a couple of properties. Is there a way to tell NSwag NOT to flatten that type into its properties when generating the OpenAPI JSON file?
Jérémy VIGNELLES
@jeremyVignelles
Don't know how webAPI/Owin works, but do you have an option to postprocess the OpenApi document as there is in asp.net core nswag?
Rico Suter
@RicoSuter
I think the complex type gets expanded into query parameters by default and thus it has to be described in the openapi spec in this way (there is no way to have complex query parameters in the spec)
Hobbes Pirakitti
@hobbes-visionfriendly-com

@RicoSuter - I'm reading the OpenAPI 3 spec, and -- If I'm understanding it correctly -- it does seem to support "objects" as query parameters https://swagger.io/docs/specification/describing-parameters/#query-parameters:

"Query parameters can be primitive values, arrays and objects"

Related to that is how query parameters can be serialized: https://swagger.io/docs/specification/serialization/

Hobbes Pirakitti
@hobbes-visionfriendly-com
@RicoSuter - Another hopefully quick question: When I call UseSwaggerUi3(), my home route gets overridden and outputs the swagger JSON. The swagger JSON also is output at the desired route ("/swagger/..."). How do I prevent this? I am using ASP.Net MVC (Full Framework, not Core).
Rico Suter
@RicoSuter
home route?
Hobbes Pirakitti
@hobbes-visionfriendly-com
Sorry, I meant that when I go to (for example) https://localhost, I get back the swagger JSON content.
cjb110
@cjb110
Hi, I'm using NSwag as part of the built in .NET 5 VS process for my Blazor WASM app and I was wondering if anyone had an example of expanding the generated client to handle JWT bearer? If not, is the basics to expand one of the PrepareRequest methods to add the bearer token? and on the ProduceResponse for the login method to get and store the token?
Jérémy VIGNELLES
@jeremyVignelles
You could do that, indeed. you could also inject your own HttpClient that you've already customized with a HttpMessageHandler that does the authentication for you. don't know about blazor wasm though
Hobbes Pirakitti
@hobbes-visionfriendly-com

@RicoSuter - I am able to reproduce my "home route" problem starting from the sample "SampleOwinWebApiWithSwaggerUi" found here: https://github.com/NSwag/Samples/tree/master/src . Steps: 1) Run the sample and confirm that the home page shows up. 2) Upgrade all NSwag NuGet packages to 13.9.4. 3) In Startup.cs, change the call "UseSwaggerUi" to

UseSwaggerUi3(typeof(Startup).Assembly, s =>
{
s.Path = "/foo";
s.SwaggerRoutes.Add(new SwaggerUi3Route("My Fancy API v1", "/qwerty/asdf.json"));
});

Now when you run the project, instead of the home page, you see that it has been "hijacked" by raw Swagger JSON.

Hobbes Pirakitti
@hobbes-visionfriendly-com
Ah, I found the solution: RicoSuter/NSwag#1797
cjb110
@cjb110

I've being using the partial client to add my JWT bearer tokens, but for some reason they don't always get added. But I can't see why.

async partial void PrepareRequest(HttpClient client, HttpRequestMessage request, string url)
        {
            _logger.LogInformation($"Prepare Request: {request.RequestUri.AbsoluteUri}");
            var user = await _storage.GetItem<LoginResult>("user");

            if (user != null)
            {
                _logger.LogInformation($"Adding Auth Header: {user.UserName}, {user.JwtToken}");
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.JwtToken);
            }
        }

I can see in the chrome log the 'Preparing Request' and 'Adding Auth Header' messages, but the request has none added...its like the client as fired off the request already?

cjb110
@cjb110
just changed in to request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", user.JwtToken); but no luck there either. Going to see if its the aysnc/awaits...
cjb110
@cjb110
Yep, it was the asynchronous part, as the client doesn't await PrepareRequest, the request is sent before the headers are added. So to fix I used the Blazord.LocalStorage package which has synchronous versions of Get/Set item.
Rico Suter
@RicoSuter
async void is almost always evil ..
cjb110
@cjb110
On the consumer side of the NSwag client, how can tell it not to pass some fields back? I've had to add some DateTime fields as the Blazor UI toolkit I'm using doesn't support the DateTimeOffset type, but these fields are being passed back to the API. I've tried JsonIgnore, doesn't seem to change things.
ooo, just noticed that the client uses the Newtonsoft Json to serialize, I think most of the rest of my client is the .net json lib.
cjb110
@cjb110
Yep that was it, need the different using statement...but meh wasn't the actual cause of my bug...
cjb110
@cjb110
Ok next issue:) The API is returning ProblemDetails, and I can see that in the actual response. I can see the generated client throws an ApiException<ProblemDetails>, how do I get to my detail message when I'm catching it?
Rico Suter
@RicoSuter
e.Result?
cjb110
@cjb110
it was, but only after i changed the catch to catch(ApiException<ProblemDetails> ex), never seen generics in exceptions before so didn't think to do that bit!
kelly
@kellyprankin
I am trying to send a File as part of a form from the front end to the backend
I added an IFormFile to my back end model and then I used TypeScript generation, but the property seemed to come out as a string instead of anything to do with a File
kelly
@kellyprankin
OK, so it looks like it works OK if you make it a separate parameter, but it will not work if it is a property on a regular class file
kelly
@kellyprankin
Guess I'll post an issue and see if anyone knows whats up
Coops9
@Coops9

Hi. I am using Nswag and generating typescript API definition from an api that has the attribute [OpenApiBodyParameter("application/octet-stream")]
//[ValidateAntiForgeryToken]
public async Task<ActionResult> Upload()

However the generated api code specifies Blob instead of File

upload(body: Blob | null | undefined): Promise<FileResponse | null> {

which generates an error when trying to read the content-type boundary. is there any other attribute I should be using so it generates the api with File instead of Blob?
related: RicoSuter/NSwag#2493

Tiago Ribeiro
@TrymBeast_twitter
Hey! What is the best way to describe a resource that is always application/zip? I have tried using the Produces attribute, but that seems to be used in conjunction with content negotiation, and I don't care about content negotiation in this resource, it will always be a zip file no matter what.
Tiago Ribeiro
@TrymBeast_twitter
Also in an IOperationProcessor I'm trying to get the response type, but I'm having some trouble finding it. Does anyone know how to get it?
Rico Suter
@RicoSuter
@Coops9 [OpenApiBodyParameter] is really the whole body and not form-data, for that i think you need to use the regular asp.net core form data constructs to get the correct openapi