-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Typescript Client Generation problem with objects being unrolled #4791
Comments
Making some progress, as I'm reading through the thread here: #4524 Looks like my nswag.json was not being read, which was a large part of the problem.
Now the vast majority of my method signatures are the same, between NSwag toolchain v13.18.2.0 and v14.0.3.0, discounting all the new I now only have one methods, out of several hundred, that is being unrolled... the same one I mentioned in my initial post. Original: Code in the controller:
Definition of SubcRtgLinkDTO:
I seem to recall running into a similar issue with IFormFile and NSwag in another application, so I'm guessing that may be what is unrolling the SubcRtgLinkDTO object into its parameters... Comparing the definition of SubcRtgLinkDTO, it does indicate it is an issue related to IFormFile.
while the new NSwag gives:
|
Spoke too soon, I found about a dozen method calls where the order of parameters changed. For example: Typescript: I'm not sure why it is seeing the id parameter as optional/nullable. |
Work around for the parameter order issue: |
@awdorrin |
We put the .net 8 migration work on hold due to these issues, and the lack of response to this issue (and other issues that have been posted here) |
Finally getting back to looking at this, and to expand on what I had above, the following appears to work.
The [BindRequired] keeps the key field for HttpPut actions at the front of the list, while [FromBody] keeps the object from being unrolled. Now I'm going through searching for a few thousand Put/Post methods and inserting these parameters and continuing to test. |
Starting with a C# Controller with a method like this:
Compiling for .Net 6, using NSwag.AspnetCore/NSwag.MSBuild 13.18.2, would generate this typescript:
putSubcRtgLink(subcontractRtgLinkId: number, subcRtgLink: SubcRtgLinkDTO): Observable<FileResponse> {
After upgrading to .Net8 and NSwag.AspnetCore/NSwag.MSBuild 14.0.3, the SubcRtgLinkDTO is being un-rolled into multiple parameters, which ends up repeating the subcontractRtgLinkId parameter, like this:
putSubcRtgLink(subcontractRtgLinkIdQuery: number | undefined, subcontractRtgLinkIdQuery: number | undefined, subcontractId: number | undefined, pmmProgramId: number | undefined, subcontractRtgId: number | undefined, fileName: string | null | undefined, fileDescription: string | null | undefined, linkAddress: string | null | undefined, sipLabel: string | null | undefined, dateAdded: DateTime | undefined, dateModified: DateTime | undefined, modifiedBy: string | null | undefined, file: FileParameter | null | undefined): Observable<FileResponse | null> {
Not sure if this is a bug, or if something changed and I need to add some new parameters to the nswag.json file.
Searched but didn't see anything related...
The text was updated successfully, but these errors were encountered: