Nswag: Difference in OffsetMomentJS between parameters in the body and in the querystring

Created on 17 Sep 2018  路  2Comments  路  Source: RicoSuter/NSwag

When generating TypeScript code with the dateTimeType set to "OffsetMomentJS" it only adjusts the offset for parameters that are in the body of a HTTP action.

this.plannedStartDate.toISOString(true)

But for parameters that are passed via the querystring the following is still used:

url_ += "start=" + encodeURIComponent(start ? "" + start.toJSON() : "") + "&";

Is it possible to change the toJSON() here to toISOString(true), keeping the offset?

bug

Most helpful comment

We need to use the logic from here also for parameters:
https://github.com/RSuter/NJsonSchema/blob/8e5bc578ee740384c0b468dcb787f4c802a51e3e/src/NJsonSchema.CodeGeneration.TypeScript/DataConversionGenerator.cs#L88

Tasks:

  • Extract this internal logic so that it can also be used for params
  • Deploy new NJS package
  • Update NSwag and use this

All 2 comments

We need to use the logic from here also for parameters:
https://github.com/RSuter/NJsonSchema/blob/8e5bc578ee740384c0b468dcb787f4c802a51e3e/src/NJsonSchema.CodeGeneration.TypeScript/DataConversionGenerator.cs#L88

Tasks:

  • Extract this internal logic so that it can also be used for params
  • Deploy new NJS package
  • Update NSwag and use this

I recently encountered the same issue, but then with moment.Duration and the conversion to TimeSpan.

Will this be fixed with the same case?

Was this page helpful?
0 / 5 - 0 ratings