-
Notifications
You must be signed in to change notification settings - Fork 333
feat(openapi3): add x-ms-duration extension support for duration encoding with round-trip via @extension 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 <7905502+baywet@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
|
@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 <7905502+baywet@users.noreply.github.com>
Added regression test in commit 09b3593. The test validates that |
|
You can try these changes here
|
Pull request was converted to draft
|
@copilot also update the OpenAPI generation to emit the extension when the encode decorator is present |
…ypes - Add x-ms-duration extension to OpenAPI output when duration type has @encode decorator - Support both seconds and milliseconds encoding - Update applyEncoding to detect duration types and add extension - Add comprehensive tests for all duration encoding scenarios with extension emission - Walk up scalar chain to detect duration as base type Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Implemented in commit d7f45bd. The OpenAPI emitter now adds the |
|
@copilot revert the change where the encode decorator generates the extension. Instead make sure the import also adds an extension decorator when the extension is present in the source document. |
…d of auto-generating extension - Revert export functionality that auto-generated x-ms-duration extension - Update import to add @extension decorator when x-ms-duration is present - Both @extension and @encode decorators are now added during import - Removes extension filtering for x-ms-duration - Update tests to expect both decorators - Enables proper round-tripping via @extension decorator Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Reverted export functionality in commit 3eab35d. The importer now adds both |
|
@copilot while running integration tests, I'm running into the following issue, regardless of the format, the encode as is always float32. Investigate and correct this behaviour. |
OpenAPI duration property import with x-ms-duration extension
This PR implements support for duration types in the OpenAPI importer using the
x-ms-durationextension, with round-trip capability via the@extensiondecorator.Changes completed:
Implementation details:
Import (OpenAPI → TypeSpec):
getNumberType()andgetIntegerType()ingenerate-types.tsto check forx-ms-durationextension (values:secondsormilliseconds)getDurationSchemaDecorators()function indecorators.tsto generate appropriate@encodedecorators based on both thex-ms-durationvalue and the schema's format (int32, float, decimal, etc.)x-ms-durationfromgetExtensions()so it's also added as an@extensiondecorator for proper round-trippingExport (TypeSpec → OpenAPI):
@extensiondecorator mechanism@extension("x-ms-duration", "seconds"), the standard extension handling emits it to OpenAPITest coverage:
data-types.test.tscovering all import scenarios from requirements table (32 tests)generate-type.test.tsfor inline type expressions (82 tests)Supported scenarios:
Example transformations:
Import (OpenAPI → TypeSpec):
Export (TypeSpec → OpenAPI) - Round-tripping:
String with duration format (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.