Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with the default param not showing in the doc #1090

Closed

Conversation

heldersepu
Copy link
Contributor

Fix Issue #1089


var schema = schemaRegistry.GetOrRegister(paramDesc.ParameterDescriptor.ParameterType);
if (parameter.@in == "body")
parameter.schema = schema;
else
parameter.PopulateFrom(schema);

parameter.@default = paramDesc.ParameterDescriptor.DefaultValue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just hit this bug myself. This is almost correct, but unfortunately reverses the existing problem. If I understand the design correctly, the default value that comes from the schema is more for scenarios like assigning 0 for number types. The HttpParameterDescriptor.DefaultValue could report null, which would cause a separate set of issues.

I think you have the sequence of assignment correct here; however, parameter.@default should only be updated when paramDesc.ParameterDescriptor.DefaultValue is not null. That will prevent it from mistakenly overriding values assigned by the schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! fixing it now...

From @commonsensesoftware
I think you have the sequence of assignment correct here; however,
parameter.@default should only be updated when
paramDesc.ParameterDescriptor.DefaultValue is not null. That will
prevent it from
mistakenly overriding values assigned by the schema.
@heldersepu
Copy link
Contributor Author

@commonsensesoftware
Please take a look at the last change, let me know if you see anything else out of place
Thanks

@commonsensesoftware
Copy link

Perfect. Thanks!

@commonsensesoftware
Copy link

The PRs seem to be merging quite slowly. Since it's basically in the same place in the code, is there any chance we can sneak at least the first half of #1101 into this PR?

This is the only thing required at or after line 190:

parameter.description = paramDesc.Documentation;

I don't mind opening a new PR, but they don't seem to be burning down. These two changes are ideal for the API Explorer about to be released for API Versioning. It will also enable API version parameters to be automatically added, documented, and contain a default value. :)

If you can't sneak it in, don't worry about it. I can eventually create a PR once yours has been merged in. Thanks.

@heldersepu
Copy link
Contributor Author

You got it! I'm adding your request...

@commonsensesoftware
Copy link

You rock! Thanks!

@heldersepu
Copy link
Contributor Author

@commonsensesoftware
If you have time can you take a look at Issue 1058...
#1058 (comment)
I could not figure out why GetApiExplorer was missing some enpoints

@heldersepu heldersepu closed this Jun 21, 2017
@commonsensesoftware
Copy link

Hey @heldersepu, did this get merged? It doesn't look like it. What happened?

@heldersepu
Copy link
Contributor Author

@commonsensesoftware, @domaindrivendev
I'm just going to focus on my own fork (and probably detach the fork in a near future)
My vision for a visual API documentation is different and this is not moving at the speed I would like.

@commonsensesoftware
Copy link

@heldersepu thanks. that's unfortunate, but I understand.

@domaindrivendev if you're able to eventually merge this PR, it would give congruence with the ASP.NET Core version. This PR contains effectively the same changes that I've submitted as 413 on the ASP.NET Core side. If not, I'll likely submit a new PR that duplicates these changes.

I'm in no rush to merge things and the changes are honestly no sweat off my back. I'm only trying improve the out-of-box experience for service authors creating versioned REST APIs that also use Swagger with Swashbuckle. I've added all the infrastructure and metadata possible to enable that, but I can't force Swashbuckle to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants