question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Matching route parameters to complex object breaks Swagger UI

See original GitHub issue

Swagger UI:

grafik

grafik

The {id} does not get replaced with the string when executing the request.

grafik

When manually replacing and doing the GET request it works.

grafik grafik

I found #513 which kind of relates to this. But it is more like the feature request for this.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ajensen11commented, Mar 29, 2021

This is still an issue.

When using SwaggerUI and the route parameter is a different case than the model’s property, then “Try It Out” fails to serialize. This works works correctly outside of SwaggerUI (e.g. Postman, HttpClients)

.. api/persons/{id}

UpdatePerson([FromRoute] Person person) { }

class Person
{
   public int Id { get; set; }
}

Debug error: “System.ArgumentException: ‘{id} is not a valid value for Int32. (Parameter ‘value’)’”

Tried and does not work:

  • JsonProperty("id")
  • [System.Text.Json.Serialization.JsonPropertyName("id")]

Changing the route to be ../person/{**Id**} works (capitalizing the parameter), but I would rather not make this change just to fix an issue with NSwag’s SwaggerUI implementation.

0reactions
youngcm2commented, Apr 1, 2020

I am experiencing the same thing with a Mongo ObjectId.

I have tried adding TypeMappers and SerializationSettings

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use object type query param in swagger documentation
I have a GET route where I would like to encode an object parameter in the url as a query string. When writing...
Read more >
Step 5: The components object (OpenAPI tutorial)
Describing the details of your parameters and describing the schema of complex responses can be the most challenging aspects of the OpenAPI ...
Read more >
Swagger PUT/POST body value issue
We're experiencing exactly the same bug. Removing ParameterType=body allows the Post function to read the values correctly, but breaks all of ...
Read more >
c# - Servicestack object parameter not getting passed to ...
Your Request DTO doesn't match the declared Swagger schema, CreditCard isn't the body it's just a parameter that has a complex type value....
Read more >
SwaggerHub On-Premise Release Notes
SwaggerHub On-Premise 2.0 must be a new installation. There is a migration path for existing 1.x instances to transfer your data to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found