microsoft / microsoft/typespec
[Bug]: Unexpected field as JSON String instead of number
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
While generating the client library for the Azure OpenAI Realtime Audio client library, I noticed that the fields `prefix_padding_ms` and `silence_duration_ms` are serialized as JSON Strings, but the service actually expects a JSON number, failing the request.
The TSP definition for the model in question can be found here: https://github.com/joseharriaga/openai-in-typespec/blob/0cd29e191a157fe4356fed68707a2c43a5f728be/.typespec/realtime/custom.tsp#L106-L115
We are fully aware that we might not be using `duration` correctly. So this could very well be a spec definition issue from our side.
### Reproduction
- Re-add the `@Generated` annotation to the fields `prefixPaddingMs` and `silenceDurationMs` in `RealtimeServerVadTurnDetection` class as well as to the `toJson` method.
- The member variables should now be generated as Java `Duration` types
- `toJson` will try to serialize these as String using `jsonWriter.writeStringField`
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Assessment
This issue has not been assessed yet.