-
Notifications
You must be signed in to change notification settings - Fork 333
feat(openapi3): convert number type with duration format to duration with @encode decorator #9412
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
base: main
Are you sure you want to change the base?
Conversation
…with @encode decorator Co-authored-by: baywet <[email protected]>
Co-authored-by: baywet <[email protected]>
|
@copilot add another unit test to validate there are no regressions if it does not exist already. The following OpenAPI description foo:
type: string
format: durationShould result in this TypeSpec bar: durationNote there are no encode attribute in that case. |
commit: |
Co-authored-by: baywet <[email protected]>
Added regression test in commit 09b3593. The test validates that |
|
You can try these changes here
|
OpenAPI duration property import fix
This PR fixes the importer to correctly convert OpenAPI
type: number, format: durationproperties to TypeSpecdurationtype with appropriate@encodedecorator.Changes completed:
numberwithdurationformat in generate-type.test.tsImplementation details:
getNumberType()ingenerate-types.tsto returndurationwhen format isdurationgetDurationSchemaDecorators()function indecorators.tsto generate@encode("seconds", float32)decorator for number types with duration formatgenerate-type.test.tsfor inline type expressiondata-types.test.tsfor scalar generation with decoratortype: string, format: durationto ensure it converts todurationwithout encode decoratorExample transformations:
Number with duration (new behavior):
String with duration (existing behavior, no regression):
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.