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

Removing invalid [FromForm] from TenantApiController.Setup (Lombiq Technologies: OCORE-191) #16439

Merged
merged 3 commits into from
Jul 14, 2024

Conversation

Piedone
Copy link
Member

@Piedone Piedone commented Jul 13, 2024

Fixes #16430.

This is backward compatible, the requests sent to the API remain the same.

@@ -295,7 +295,7 @@ public async Task<IActionResult> Remove(string tenantName)

[HttpPost]
[Route("setup")]
public async Task<ActionResult> Setup(SetupApiViewModel model, [FromForm] IFormFile recipe = null)
Copy link
Member

Choose a reason for hiding this comment

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

How this backward compatible while the old one accepts a file not a JSON string?

Copy link
Member Author

Choose a reason for hiding this comment

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

The old one doesn't expect a file either. For that, as well as for the new one, the HTTP request is something like this, with the recipe passed in being part of the JSON body:

{"name":"ApiClientTenant638565081195196341","siteName":"Api Client Tenant Site","databaseProvider":"Sqlite","connectionString":"","tablePrefix":"apiclienttenant638565081195196341","userName":"admin","email":"admin@example.com","password":"Password1!","recipeName":null,"Recipe":"{\r\n  \u0022name\u0022: \u0022Agency\u0022,}\r\n","siteTimeZone":"Europe/Budapest"}

Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why the IFormFile was there :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I won't be able to answer that.

Copy link
Contributor

Choose a reason for hiding this comment

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

This parameter was added in this PR, but before that it was a property in SetupApiViewModel ever since the tenant API was introduced. So I guess moving it into a standalone parameter was just for the sake of adding [FromForm]. I don't see any related changes to moving from SetupApiViewModel.Recipe to recipe in #14058, so it's a safe bet that this optional pathway was dead code.

@hishamco
Copy link
Member

Can we have a test for this one?

@Piedone
Copy link
Member Author

Piedone commented Jul 14, 2024

I don't think it makes too much sense to test a controller action, apart from a UI test. How would you test it?

@hishamco
Copy link
Member

It could be a functional test, anyhow let's merge if you are test it. I trust you ;)

@Piedone
Copy link
Member Author

Piedone commented Jul 14, 2024

We don't have a framework set up for functional tests apart from the JS ones, which I won't be able to extend (nor see much point to it either). BTW I used https://github.com/Lombiq/Orchard-Core-API-Client to make sure that this works the same as before.

Thanks!

@Piedone Piedone merged commit 29cd5fb into OrchardCMS:main Jul 14, 2024
36 checks passed
@hishamco
Copy link
Member

BTW I used https://github.com/Lombiq/Orchard-Core-API-Client to make sure that this works the same as before.

Nice, I want to point to it but thanks that you mentioned

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.

TenantApiController.Setup has supposedly unneeded [FromForm], failing Swagger
3 participants