@typespec/http-client-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.testignore +2 -0
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/babel.config.js +4 -0
- package/dist/src/components/client-context/client-context-declaration.d.ts +8 -0
- package/dist/src/components/client-context/client-context-declaration.d.ts.map +1 -0
- package/dist/src/components/client-context/client-context-declaration.js +21 -0
- package/dist/src/components/client-context/client-context-declaration.js.map +1 -0
- package/dist/src/components/client-context/client-context-factory.d.ts +8 -0
- package/dist/src/components/client-context/client-context-factory.d.ts.map +1 -0
- package/dist/src/components/client-context/client-context-factory.js +154 -0
- package/dist/src/components/client-context/client-context-factory.js.map +1 -0
- package/dist/src/components/client-context/client-context-options.d.ts +8 -0
- package/dist/src/components/client-context/client-context-options.d.ts.map +1 -0
- package/dist/src/components/client-context/client-context-options.js +42 -0
- package/dist/src/components/client-context/client-context-options.js.map +1 -0
- package/dist/src/components/client-context/client-context.d.ts +8 -0
- package/dist/src/components/client-context/client-context.d.ts.map +1 -0
- package/dist/src/components/client-context/client-context.js +33 -0
- package/dist/src/components/client-context/client-context.js.map +1 -0
- package/dist/src/components/client-context/parametrized-endpoint.d.ts +9 -0
- package/dist/src/components/client-context/parametrized-endpoint.d.ts.map +1 -0
- package/dist/src/components/client-context/parametrized-endpoint.js +48 -0
- package/dist/src/components/client-context/parametrized-endpoint.js.map +1 -0
- package/dist/src/components/client-directory.d.ts +11 -0
- package/dist/src/components/client-directory.d.ts.map +1 -0
- package/dist/src/components/client-directory.js +39 -0
- package/dist/src/components/client-directory.js.map +1 -0
- package/dist/src/components/client-operation.d.ts +11 -0
- package/dist/src/components/client-operation.d.ts.map +1 -0
- package/dist/src/components/client-operation.js +74 -0
- package/dist/src/components/client-operation.js.map +1 -0
- package/dist/src/components/client.d.ts +15 -0
- package/dist/src/components/client.d.ts.map +1 -0
- package/dist/src/components/client.js +153 -0
- package/dist/src/components/client.js.map +1 -0
- package/dist/src/components/encoding-provider.d.ts +8 -0
- package/dist/src/components/encoding-provider.d.ts.map +1 -0
- package/dist/src/components/encoding-provider.js +17 -0
- package/dist/src/components/encoding-provider.js.map +1 -0
- package/dist/src/components/external-packages/ts-http-runtime.d.ts +13 -0
- package/dist/src/components/external-packages/ts-http-runtime.d.ts.map +1 -0
- package/dist/src/components/external-packages/ts-http-runtime.js +11 -0
- package/dist/src/components/external-packages/ts-http-runtime.js.map +1 -0
- package/dist/src/components/external-packages/uri-template.d.ts +4 -0
- package/dist/src/components/external-packages/uri-template.d.ts.map +1 -0
- package/dist/src/components/external-packages/uri-template.js +11 -0
- package/dist/src/components/external-packages/uri-template.js.map +1 -0
- package/dist/src/components/http-request-options.d.ts +25 -0
- package/dist/src/components/http-request-options.d.ts.map +1 -0
- package/dist/src/components/http-request-options.js +74 -0
- package/dist/src/components/http-request-options.js.map +1 -0
- package/dist/src/components/http-request-parameters-expression.d.ts +10 -0
- package/dist/src/components/http-request-parameters-expression.d.ts.map +1 -0
- package/dist/src/components/http-request-parameters-expression.js +62 -0
- package/dist/src/components/http-request-parameters-expression.js.map +1 -0
- package/dist/src/components/http-request.d.ts +16 -0
- package/dist/src/components/http-request.d.ts.map +1 -0
- package/dist/src/components/http-request.js +70 -0
- package/dist/src/components/http-request.js.map +1 -0
- package/dist/src/components/http-response.d.ts +14 -0
- package/dist/src/components/http-response.d.ts.map +1 -0
- package/dist/src/components/http-response.js +61 -0
- package/dist/src/components/http-response.js.map +1 -0
- package/dist/src/components/models.d.ts +5 -0
- package/dist/src/components/models.d.ts.map +1 -0
- package/dist/src/components/models.js +41 -0
- package/dist/src/components/models.js.map +1 -0
- package/dist/src/components/operation-options.d.ts +8 -0
- package/dist/src/components/operation-options.d.ts.map +1 -0
- package/dist/src/components/operation-options.js +41 -0
- package/dist/src/components/operation-options.js.map +1 -0
- package/dist/src/components/operation-parameters.d.ts +9 -0
- package/dist/src/components/operation-parameters.d.ts.map +1 -0
- package/dist/src/components/operation-parameters.js +33 -0
- package/dist/src/components/operation-parameters.js.map +1 -0
- package/dist/src/components/output.d.ts +6 -0
- package/dist/src/components/output.d.ts.map +1 -0
- package/dist/src/components/output.js +35 -0
- package/dist/src/components/output.js.map +1 -0
- package/dist/src/components/serializers.d.ts +5 -0
- package/dist/src/components/serializers.d.ts.map +1 -0
- package/dist/src/components/serializers.js +43 -0
- package/dist/src/components/serializers.js.map +1 -0
- package/dist/src/components/static-helpers/bytes-encoding.d.ts +6 -0
- package/dist/src/components/static-helpers/bytes-encoding.d.ts.map +1 -0
- package/dist/src/components/static-helpers/bytes-encoding.js +68 -0
- package/dist/src/components/static-helpers/bytes-encoding.js.map +1 -0
- package/dist/src/components/static-helpers/interfaces.d.ts +5 -0
- package/dist/src/components/static-helpers/interfaces.d.ts.map +1 -0
- package/dist/src/components/static-helpers/interfaces.js +41 -0
- package/dist/src/components/static-helpers/interfaces.js.map +1 -0
- package/dist/src/components/static-helpers/multipart-helpers.d.ts +8 -0
- package/dist/src/components/static-helpers/multipart-helpers.d.ts.map +1 -0
- package/dist/src/components/static-helpers/multipart-helpers.js +83 -0
- package/dist/src/components/static-helpers/multipart-helpers.js.map +1 -0
- package/dist/src/components/static-helpers/rest-error.d.ts +5 -0
- package/dist/src/components/static-helpers/rest-error.d.ts.map +1 -0
- package/dist/src/components/static-helpers/rest-error.js +127 -0
- package/dist/src/components/static-helpers/rest-error.js.map +1 -0
- package/dist/src/components/testing/client-options.d.ts +8 -0
- package/dist/src/components/testing/client-options.d.ts.map +1 -0
- package/dist/src/components/testing/client-options.js +27 -0
- package/dist/src/components/testing/client-options.js.map +1 -0
- package/dist/src/components/transforms/content-type-encoding-provider.d.ts +7 -0
- package/dist/src/components/transforms/content-type-encoding-provider.d.ts.map +1 -0
- package/dist/src/components/transforms/content-type-encoding-provider.js +25 -0
- package/dist/src/components/transforms/content-type-encoding-provider.js.map +1 -0
- package/dist/src/components/transforms/data-transform.d.ts +9 -0
- package/dist/src/components/transforms/data-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/data-transform.js +31 -0
- package/dist/src/components/transforms/data-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-array-transform.d.ts +15 -0
- package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-array-transform.js +71 -0
- package/dist/src/components/transforms/json/json-array-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts +9 -0
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.js +35 -0
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-model-base-transform.d.ts +9 -0
- package/dist/src/components/transforms/json/json-model-base-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-model-base-transform.js +13 -0
- package/dist/src/components/transforms/json/json-model-base-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-model-property-transform.d.ts +9 -0
- package/dist/src/components/transforms/json/json-model-property-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-model-property-transform.js +44 -0
- package/dist/src/components/transforms/json/json-model-property-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-model-transform.d.ts +15 -0
- package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-model-transform.js +96 -0
- package/dist/src/components/transforms/json/json-model-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-record-transform.d.ts +15 -0
- package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-record-transform.js +71 -0
- package/dist/src/components/transforms/json/json-record-transform.js.map +1 -0
- package/dist/src/components/transforms/json/json-transform-discriminator.d.ts +16 -0
- package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-transform-discriminator.js +82 -0
- package/dist/src/components/transforms/json/json-transform-discriminator.js.map +1 -0
- package/dist/src/components/transforms/json/json-transform.d.ts +14 -0
- package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/json-transform.js +149 -0
- package/dist/src/components/transforms/json/json-transform.js.map +1 -0
- package/dist/src/components/transforms/json/union-transform.d.ts +15 -0
- package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/json/union-transform.js +67 -0
- package/dist/src/components/transforms/json/union-transform.js.map +1 -0
- package/dist/src/components/transforms/json/utils/transport-namer.d.ts +3 -0
- package/dist/src/components/transforms/json/utils/transport-namer.d.ts.map +1 -0
- package/dist/src/components/transforms/json/utils/transport-namer.js +13 -0
- package/dist/src/components/transforms/json/utils/transport-namer.js.map +1 -0
- package/dist/src/components/transforms/multipart/array-part-transform.d.ts +8 -0
- package/dist/src/components/transforms/multipart/array-part-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/multipart/array-part-transform.js +29 -0
- package/dist/src/components/transforms/multipart/array-part-transform.js.map +1 -0
- package/dist/src/components/transforms/multipart/file-part-transform.d.ts +8 -0
- package/dist/src/components/transforms/multipart/file-part-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/multipart/file-part-transform.js +40 -0
- package/dist/src/components/transforms/multipart/file-part-transform.js.map +1 -0
- package/dist/src/components/transforms/multipart/multipart-transform.d.ts +7 -0
- package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/multipart/multipart-transform.js +26 -0
- package/dist/src/components/transforms/multipart/multipart-transform.js.map +1 -0
- package/dist/src/components/transforms/multipart/part-transform.d.ts +8 -0
- package/dist/src/components/transforms/multipart/part-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/multipart/part-transform.js +35 -0
- package/dist/src/components/transforms/multipart/part-transform.js.map +1 -0
- package/dist/src/components/transforms/multipart/simple-part-transform.d.ts +8 -0
- package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/multipart/simple-part-transform.js +48 -0
- package/dist/src/components/transforms/multipart/simple-part-transform.js.map +1 -0
- package/dist/src/components/transforms/operation-transform-declaration.d.ts +17 -0
- package/dist/src/components/transforms/operation-transform-declaration.d.ts.map +1 -0
- package/dist/src/components/transforms/operation-transform-declaration.js +74 -0
- package/dist/src/components/transforms/operation-transform-declaration.js.map +1 -0
- package/dist/src/components/transforms/operation-transform-expression.d.ts +6 -0
- package/dist/src/components/transforms/operation-transform-expression.d.ts.map +1 -0
- package/dist/src/components/transforms/operation-transform-expression.js +60 -0
- package/dist/src/components/transforms/operation-transform-expression.js.map +1 -0
- package/dist/src/components/transforms/scalar-transform.d.ts +15 -0
- package/dist/src/components/transforms/scalar-transform.d.ts.map +1 -0
- package/dist/src/components/transforms/scalar-transform.js +317 -0
- package/dist/src/components/transforms/scalar-transform.js.map +1 -0
- package/dist/src/components/transforms/transform-name-policy.d.ts +71 -0
- package/dist/src/components/transforms/transform-name-policy.d.ts.map +1 -0
- package/dist/src/components/transforms/transform-name-policy.js +111 -0
- package/dist/src/components/transforms/transform-name-policy.js.map +1 -0
- package/dist/src/components/utils/unpack-model-property.d.ts +8 -0
- package/dist/src/components/utils/unpack-model-property.d.ts.map +1 -0
- package/dist/src/components/utils/unpack-model-property.js +33 -0
- package/dist/src/components/utils/unpack-model-property.js.map +1 -0
- package/dist/src/components/utils/url-template.d.ts +7 -0
- package/dist/src/components/utils/url-template.d.ts.map +1 -0
- package/dist/src/components/utils/url-template.js +23 -0
- package/dist/src/components/utils/url-template.js.map +1 -0
- package/dist/src/context/encoding/encoding-context.d.ts +6 -0
- package/dist/src/context/encoding/encoding-context.d.ts.map +1 -0
- package/dist/src/context/encoding/encoding-context.js +20 -0
- package/dist/src/context/encoding/encoding-context.js.map +1 -0
- package/dist/src/context/encoding/types.d.ts +6 -0
- package/dist/src/context/encoding/types.d.ts.map +1 -0
- package/dist/src/context/encoding/types.js +1 -0
- package/dist/src/context/encoding/types.js.map +1 -0
- package/dist/src/emitter.d.ts +8 -0
- package/dist/src/emitter.d.ts.map +1 -0
- package/dist/src/emitter.js +68 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +206 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +107 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +8 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/utils/client-discovery.d.ts +7 -0
- package/dist/src/utils/client-discovery.d.ts.map +1 -0
- package/dist/src/utils/client-discovery.js +26 -0
- package/dist/src/utils/client-discovery.js.map +1 -0
- package/dist/src/utils/multipart.d.ts +3 -0
- package/dist/src/utils/multipart.d.ts.map +1 -0
- package/dist/src/utils/multipart.js +26 -0
- package/dist/src/utils/multipart.js.map +1 -0
- package/dist/src/utils/operations.d.ts +3 -0
- package/dist/src/utils/operations.d.ts.map +1 -0
- package/dist/src/utils/operations.js +11 -0
- package/dist/src/utils/operations.js.map +1 -0
- package/dist/src/utils/parameters.d.ts +14 -0
- package/dist/src/utils/parameters.d.ts.map +1 -0
- package/dist/src/utils/parameters.js +98 -0
- package/dist/src/utils/parameters.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eng/scripts/calculate-coverage.js +36 -0
- package/eng/scripts/emit-e2e.js +329 -0
- package/eng/scripts/run-e2e-tests.js +162 -0
- package/eng/scripts/tspconfig.yaml +6 -0
- package/eng/scripts/upload-spector-results.js +120 -0
- package/package.json +83 -0
- package/src/components/client-context/client-context-declaration.tsx +19 -0
- package/src/components/client-context/client-context-factory.tsx +142 -0
- package/src/components/client-context/client-context-options.tsx +28 -0
- package/src/components/client-context/client-context.tsx +21 -0
- package/src/components/client-context/parametrized-endpoint.tsx +39 -0
- package/src/components/client-directory.tsx +40 -0
- package/src/components/client-operation.tsx +52 -0
- package/src/components/client.tsx +137 -0
- package/src/components/encoding-provider.tsx +19 -0
- package/src/components/external-packages/ts-http-runtime.ts +22 -0
- package/src/components/external-packages/uri-template.ts +11 -0
- package/src/components/http-request-options.tsx +69 -0
- package/src/components/http-request-parameters-expression.tsx +69 -0
- package/src/components/http-request.tsx +58 -0
- package/src/components/http-response.tsx +68 -0
- package/src/components/models.tsx +29 -0
- package/src/components/operation-options.tsx +26 -0
- package/src/components/operation-parameters.tsx +43 -0
- package/src/components/output.tsx +26 -0
- package/src/components/serializers.tsx +47 -0
- package/src/components/static-helpers/bytes-encoding.tsx +41 -0
- package/src/components/static-helpers/interfaces.tsx +26 -0
- package/src/components/static-helpers/multipart-helpers.tsx +59 -0
- package/src/components/static-helpers/rest-error.tsx +61 -0
- package/src/components/testing/client-options.tsx +32 -0
- package/src/components/transforms/content-type-encoding-provider.tsx +28 -0
- package/src/components/transforms/data-transform.tsx +39 -0
- package/src/components/transforms/json/json-array-transform.tsx +83 -0
- package/src/components/transforms/json/json-model-additional-properties-transform.tsx +47 -0
- package/src/components/transforms/json/json-model-base-transform.tsx +19 -0
- package/src/components/transforms/json/json-model-property-transform.tsx +41 -0
- package/src/components/transforms/json/json-model-transform.tsx +87 -0
- package/src/components/transforms/json/json-record-transform.tsx +84 -0
- package/src/components/transforms/json/json-transform-discriminator.tsx +114 -0
- package/src/components/transforms/json/json-transform.tsx +113 -0
- package/src/components/transforms/json/union-transform.tsx +73 -0
- package/src/components/transforms/json/utils/transport-namer.ts +12 -0
- package/src/components/transforms/multipart/array-part-transform.tsx +40 -0
- package/src/components/transforms/multipart/file-part-transform.tsx +44 -0
- package/src/components/transforms/multipart/multipart-transform.tsx +32 -0
- package/src/components/transforms/multipart/part-transform.tsx +22 -0
- package/src/components/transforms/multipart/simple-part-transform.tsx +49 -0
- package/src/components/transforms/operation-transform-declaration.tsx +64 -0
- package/src/components/transforms/operation-transform-expression.tsx +54 -0
- package/src/components/transforms/scalar-transform.tsx +289 -0
- package/src/components/transforms/transform-name-policy.ts +133 -0
- package/src/components/utils/unpack-model-property.ts +31 -0
- package/src/components/utils/url-template.tsx +21 -0
- package/src/context/encoding/encoding-context.tsx +26 -0
- package/src/context/encoding/types.ts +6 -0
- package/src/emitter.tsx +53 -0
- package/src/index.ts +5 -0
- package/src/lib.ts +108 -0
- package/src/testing/index.ts +8 -0
- package/src/utils/client-discovery.ts +28 -0
- package/src/utils/multipart.ts +28 -0
- package/src/utils/operations.ts +14 -0
- package/src/utils/parameters.tsx +129 -0
- package/test/e2e/assets/image.jpg +0 -0
- package/test/e2e/assets/image.png +0 -0
- package/test/e2e/http/authentication/api-key/main.test.ts +38 -0
- package/test/e2e/http/authentication/oauth2/main.test.ts +41 -0
- package/test/e2e/http/authentication/union/main.test.ts +29 -0
- package/test/e2e/http/encode/bytes/main.test.ts +191 -0
- package/test/e2e/http/encode/datetime/main.test.ts +176 -0
- package/test/e2e/http/encode/duration/main.test.ts +126 -0
- package/test/e2e/http/encode/numeric/main.test.ts +26 -0
- package/test/e2e/http/parameters/basic/main.test.ts +35 -0
- package/test/e2e/http/parameters/body-optionality/main.test.ts +43 -0
- package/test/e2e/http/parameters/collection-format/main.test.ts +45 -0
- package/test/e2e/http/parameters/spread/main.test.ts +56 -0
- package/test/e2e/http/payload/content-negotiation/main.test.ts +40 -0
- package/test/e2e/http/payload/json-merge-patch/main.test.ts +122 -0
- package/test/e2e/http/payload/media-type/main.test.ts +28 -0
- package/test/e2e/http/payload/multipart/main.test.ts +164 -0
- package/test/e2e/http/payload/pageable/main.test.ts +24 -0
- package/test/e2e/http/payload/xml/main.test.ts +287 -0
- package/test/e2e/http/routes/main.test.ts +284 -0
- package/test/e2e/http/serialization/encoded-name/json/main.test.ts +20 -0
- package/test/e2e/http/server/endpoint/not-defined/main.test.ts +11 -0
- package/test/e2e/http/server/path/multiple/main.test.ts +22 -0
- package/test/e2e/http/server/path/single/main.test.ts +11 -0
- package/test/e2e/http/server/versions/not-versioned/main.test.ts +22 -0
- package/test/e2e/http/server/versions/versioned/main.test.ts +28 -0
- package/test/e2e/http/special-headers/conditional-request/main.test.ts +35 -0
- package/test/e2e/http/special-headers/repeatability/main.test.ts +18 -0
- package/test/e2e/http/special-words/main.test.ts +434 -0
- package/test/e2e/http/type/array/array.test.ts +256 -0
- package/test/e2e/http/type/dictionary/main.test.ts +229 -0
- package/test/e2e/http/type/enum/extensible/main.test.ts +34 -0
- package/test/e2e/http/type/enum/fixed/main.test.ts +29 -0
- package/test/e2e/http/type/model/empty/main.test.ts +21 -0
- package/test/e2e/http/type/model/inheritance/enum-discriminator/main.test.ts +51 -0
- package/test/e2e/http/type/model/inheritance/nested-discriminator/main.test.ts +168 -0
- package/test/e2e/http/type/model/inheritance/not-discriminated/main.test.ts +42 -0
- package/test/e2e/http/type/model/inheritance/recursive/main.test.ts +46 -0
- package/test/e2e/http/type/model/inheritance/single-discriminator/main.test.ts +101 -0
- package/test/e2e/http/type/model/visibility/main.test.ts +64 -0
- package/test/e2e/http/type/property/additional-properties/main.test.ts +185 -0
- package/test/e2e/http/type/property/additional-properties/spreads.test.ts +470 -0
- package/test/e2e/http/type/property/nullable/main.test.ts +275 -0
- package/test/e2e/http/type/property/optionality/main.test.ts +256 -0
- package/test/e2e/http/type/property/value-types/main.test.ts +193 -0
- package/test/e2e/http/type/scalar/main.test.ts +133 -0
- package/test/e2e/http/type/scalar/scalar.test.ts +95 -0
- package/test/e2e/http/type/union/main.test.ts +207 -0
- package/test/e2e/http/versioning/added/main.test.ts +61 -0
- package/test/e2e/http/versioning/madeOptional/main.test.ts +34 -0
- package/test/e2e/http/versioning/removed/main.test.ts +75 -0
- package/test/e2e/http/versioning/renamedFrom/main.test.ts +52 -0
- package/test/e2e/http/versioning/returnTypeChangedFrom/main.test.ts +22 -0
- package/test/e2e/http/versioning/typeChangedFrom/main.test.ts +31 -0
- package/test/scenarios/additional-properties/extends.md +71 -0
- package/test/scenarios/additional-properties/is.md +46 -0
- package/test/scenarios/additional-properties/spread.md +72 -0
- package/test/scenarios/auth/basic_auth.md +67 -0
- package/test/scenarios/auth/bearer.md +67 -0
- package/test/scenarios/auth/client_parameters.md +68 -0
- package/test/scenarios/auth/client_structure.md +38 -0
- package/test/scenarios/auth/key_credential.md +67 -0
- package/test/scenarios/auth/sub_client_override.md +114 -0
- package/test/scenarios/client/client_context.md +36 -0
- package/test/scenarios/client/dotted_namespace.md +30 -0
- package/test/scenarios/client/global_namespace.md +74 -0
- package/test/scenarios/client/multiple_top_level_clients.md +74 -0
- package/test/scenarios/client/nested_client.md +106 -0
- package/test/scenarios/client/wrapping_namespace.md +43 -0
- package/test/scenarios/encoding/bytes_body.md +48 -0
- package/test/scenarios/encoding/bytes_json_property.md +60 -0
- package/test/scenarios/encoding/bytes_nullable.md +153 -0
- package/test/scenarios/encoding/header_bytes.md +142 -0
- package/test/scenarios/encoding/header_date.md +236 -0
- package/test/scenarios/encoding/model_with_bytes_property.md +50 -0
- package/test/scenarios/encoding/query_bytes.md +46 -0
- package/test/scenarios/encoding/query_date.md +236 -0
- package/test/scenarios/http-operations/basic-request.md +162 -0
- package/test/scenarios/http-operations/basic-response.md +246 -0
- package/test/scenarios/http-operations/basic.md +134 -0
- package/test/scenarios/http-operations/constant-header.md +37 -0
- package/test/scenarios/http-operations/create-operation.md +62 -0
- package/test/scenarios/http-operations/on_response.md +56 -0
- package/test/scenarios/http-operations/optional-request-body.md +55 -0
- package/test/scenarios/http-operations/path-parameter-in-model.md +59 -0
- package/test/scenarios/http-operations/path-parameter.md +54 -0
- package/test/scenarios/http-operations/scalar-payload.md +63 -0
- package/test/scenarios/http-operations/with-parameters.md +85 -0
- package/test/scenarios/models/array-properties.md +47 -0
- package/test/scenarios/models/basic.md +118 -0
- package/test/scenarios/models/dictionary-properties.md +44 -0
- package/test/scenarios/models/inheritance_2_discriminators.md +370 -0
- package/test/scenarios/models/inheritance_discriminator.md +92 -0
- package/test/scenarios/models/inline-models.md +29 -0
- package/test/scenarios/models/model_additional_properties.md +79 -0
- package/test/scenarios/models/model_extends.md +101 -0
- package/test/scenarios/models/model_spread.md +65 -0
- package/test/scenarios/models/nested_property.md +45 -0
- package/test/scenarios/models/property_references_property.md +156 -0
- package/test/scenarios/multipart/anonymous_part.md +57 -0
- package/test/scenarios/multipart/file.md +166 -0
- package/test/scenarios/multipart/file_content_type.md +67 -0
- package/test/scenarios/multipart/simple_part.md +69 -0
- package/test/scenarios/operation-parameters/body_root_anonymous.md +92 -0
- package/test/scenarios/operation-parameters/constant_as_optional.md +59 -0
- package/test/scenarios/operation-parameters/default_value_as_optional.md +59 -0
- package/test/scenarios/operation-parameters/no_content_type.md +67 -0
- package/test/scenarios/operation-parameters/no_parameters.md +55 -0
- package/test/scenarios/operation-parameters/only_optional.md +67 -0
- package/test/scenarios/operation-parameters/only_required.md +63 -0
- package/test/scenarios/operation-parameters/reserved_names.md +65 -0
- package/test/scenarios/operation-parameters/spread_body.md +75 -0
- package/test/scenarios/operation-parameters/spread_with_nested.md +87 -0
- package/test/scenarios/operation-parameters/union_body.md +92 -0
- package/test/scenarios/operation-parameters/with_body_property.md +72 -0
- package/test/scenarios/operation-parameters/with_body_root.md +74 -0
- package/test/scenarios/serializers/arrays.md +199 -0
- package/test/scenarios/serializers/basic_model.md +115 -0
- package/test/scenarios/serializers/basic_model_wire_name.md +50 -0
- package/test/scenarios/serializers/discriminated_union.md +86 -0
- package/test/scenarios/serializers/discriminated_union_spread.md +119 -0
- package/test/scenarios/serializers/model_date_time.md +65 -0
- package/test/scenarios/serializers/multipart.md +66 -0
- package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +164 -0
- package/test/scenarios/serializers/record.md +101 -0
- package/test/scenarios/serializers/scalars.md +33 -0
- package/test/scenarios/serializers/spread.md +75 -0
- package/test/scenarios/serializers/string_union.md +61 -0
- package/test/scenarios/server/default_url.md +45 -0
- package/test/scenarios/server/multiple-parameters.md +57 -0
- package/test/scenarios/server/no-server.md +37 -0
- package/test/scenarios/server/parametrized-endpoint.md +53 -0
- package/test/scenarios.test.ts +18 -0
- package/test/test-host.ts +76 -0
- package/tsconfig.json +16 -0
- package/tsconfig.test.json +7 -0
- package/vitest.config.js +23 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { OAuth2Client } from "../../../generated/authentication/oauth2/src/index.js";
|
|
3
|
+
|
|
4
|
+
describe("Authentication.OAuth2", () => {
|
|
5
|
+
const client = new OAuth2Client(
|
|
6
|
+
{
|
|
7
|
+
getToken: async () => ({
|
|
8
|
+
token: "Bearer https://security.microsoft.com/.default",
|
|
9
|
+
expiresOnTimestamp: Date.now() + 3600 * 1000,
|
|
10
|
+
}),
|
|
11
|
+
},
|
|
12
|
+
{ allowInsecureConnection: true },
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
it.skip("should validate the client is authenticated", async () => {
|
|
16
|
+
const response = await client.valid();
|
|
17
|
+
expect(response).toBe(undefined); // No content response
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it.skip("should handle invalid authentication and return error", async () => {
|
|
21
|
+
try {
|
|
22
|
+
const client = new OAuth2Client(
|
|
23
|
+
{
|
|
24
|
+
getToken: async () => ({
|
|
25
|
+
token: "invalid",
|
|
26
|
+
expiresOnTimestamp: Date.now() + 3600 * 1000,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
{ allowInsecureConnection: true },
|
|
30
|
+
);
|
|
31
|
+
await client.invalid();
|
|
32
|
+
} catch (error: any) {
|
|
33
|
+
expect(error.statusCode).toBe(403);
|
|
34
|
+
expect(error.error).toMatchObject({
|
|
35
|
+
message: "Expected Bearer x but got Bearer y",
|
|
36
|
+
expected: "Bearer x",
|
|
37
|
+
actual: "Bearer y",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it } from "vitest";
|
|
2
|
+
import { UnionClient } from "../../../generated/authentication/union/src/index.js";
|
|
3
|
+
|
|
4
|
+
describe("Authentication.Union", () => {
|
|
5
|
+
it("should authenticate using the valid API key", async () => {
|
|
6
|
+
const client = new UnionClient(
|
|
7
|
+
{
|
|
8
|
+
key: "valid-key",
|
|
9
|
+
},
|
|
10
|
+
{ allowInsecureConnection: true },
|
|
11
|
+
);
|
|
12
|
+
await client.validKey();
|
|
13
|
+
// Assert successful request
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it.skip("should authenticate using the valid OAuth token", async () => {
|
|
17
|
+
const client = new UnionClient(
|
|
18
|
+
{
|
|
19
|
+
getToken: async () => ({
|
|
20
|
+
token: "Bearer https://security.microsoft.com/.default",
|
|
21
|
+
expiresOnTimestamp: Date.now() + 3600 * 1000,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
{ allowInsecureConnection: true },
|
|
25
|
+
);
|
|
26
|
+
await client.validToken();
|
|
27
|
+
// Assert successful request
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { dirname, resolve } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import {
|
|
6
|
+
HeaderClient,
|
|
7
|
+
PropertyClient,
|
|
8
|
+
QueryClient,
|
|
9
|
+
RequestBodyClient,
|
|
10
|
+
ResponseBodyClient,
|
|
11
|
+
} from "../../../generated/encode/bytes/src/index.js";
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
|
|
16
|
+
const pngImagePath = resolve(
|
|
17
|
+
__dirname,
|
|
18
|
+
"../../../../../node_modules/@typespec/http-specs/assets/image.png",
|
|
19
|
+
);
|
|
20
|
+
const pngBuffer = await readFile(pngImagePath);
|
|
21
|
+
const pngContents = new Uint8Array(pngBuffer);
|
|
22
|
+
|
|
23
|
+
const base64EncodeToUint8Array = (input: string): Uint8Array => {
|
|
24
|
+
// Encode the string as Base64
|
|
25
|
+
const base64String = btoa(input);
|
|
26
|
+
|
|
27
|
+
// Decode Base64 into a binary string
|
|
28
|
+
const binaryString = atob(base64String);
|
|
29
|
+
|
|
30
|
+
// Convert the binary string to a Uint8Array
|
|
31
|
+
const uint8Array = new Uint8Array(binaryString.length);
|
|
32
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
33
|
+
uint8Array[i] = binaryString.charCodeAt(i);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return uint8Array;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const encodedTestString = base64EncodeToUint8Array("test");
|
|
40
|
+
|
|
41
|
+
const str = "test";
|
|
42
|
+
const testUint8Array = new Uint8Array([...str].map((char) => char.charCodeAt(0)));
|
|
43
|
+
|
|
44
|
+
describe("Encode.Bytes", () => {
|
|
45
|
+
describe("QueryClient", () => {
|
|
46
|
+
const client = new QueryClient({ allowInsecureConnection: true });
|
|
47
|
+
|
|
48
|
+
it.skip("should test default encode (base64) for bytes query parameter", async () => {
|
|
49
|
+
//
|
|
50
|
+
await client.default_(testUint8Array);
|
|
51
|
+
// Assert successful request
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should test base64 encode for bytes query parameter", async () => {
|
|
55
|
+
await client.base64(testUint8Array);
|
|
56
|
+
// Assert successful request
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("should test base64url encode for bytes query parameter", async () => {
|
|
60
|
+
await client.base64url(testUint8Array);
|
|
61
|
+
// Assert successful request
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("should test base64url encode for bytes array query parameter", async () => {
|
|
65
|
+
await client.base64urlArray([testUint8Array, testUint8Array]);
|
|
66
|
+
// Assert successful request
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("PropertyClient", () => {
|
|
71
|
+
const client = new PropertyClient({ allowInsecureConnection: true });
|
|
72
|
+
|
|
73
|
+
it("should test default encode (base64) for bytes properties", async () => {
|
|
74
|
+
const response = await client.default_({ value: encodedTestString });
|
|
75
|
+
expect(response.value).toStrictEqual(encodedTestString);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should test base64 encode for bytes properties", async () => {
|
|
79
|
+
const response = await client.base64({ value: testUint8Array });
|
|
80
|
+
expect(response.value).toStrictEqual(encodedTestString);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should test base64url encode for bytes properties", async () => {
|
|
84
|
+
const response = await client.base64url({ value: testUint8Array });
|
|
85
|
+
expect(response.value).toStrictEqual(encodedTestString);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should test base64url encode for bytes array properties", async () => {
|
|
89
|
+
const response = await client.base64urlArray({
|
|
90
|
+
value: [testUint8Array, testUint8Array],
|
|
91
|
+
});
|
|
92
|
+
expect(response.value).toStrictEqual([testUint8Array, testUint8Array]);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe("HeaderClient", () => {
|
|
97
|
+
const client = new HeaderClient({ allowInsecureConnection: true });
|
|
98
|
+
|
|
99
|
+
it("should test default encode (base64) for bytes header", async () => {
|
|
100
|
+
await client.default_(testUint8Array);
|
|
101
|
+
// Assert successful request
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("should test base64 encode for bytes header", async () => {
|
|
105
|
+
await client.base64(testUint8Array);
|
|
106
|
+
// Assert successful request
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should test base64url encode for bytes header", async () => {
|
|
110
|
+
await client.base64url(testUint8Array);
|
|
111
|
+
// Assert successful request
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should test base64url encode for bytes array header", async () => {
|
|
115
|
+
await client.base64urlArray([encodedTestString, encodedTestString]);
|
|
116
|
+
// Assert successful request
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("RequestBodyClient", () => {
|
|
121
|
+
const client = new RequestBodyClient({
|
|
122
|
+
allowInsecureConnection: true,
|
|
123
|
+
retryOptions: {
|
|
124
|
+
maxRetries: 1,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it.skip("should test default encode (base64) for bytes in JSON body", async () => {
|
|
129
|
+
await client.default_(encodedTestString);
|
|
130
|
+
// Assert successful request
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should test application/octet-stream content type with bytes payload", async () => {
|
|
134
|
+
const content = pngContents;
|
|
135
|
+
await client.octetStream(content);
|
|
136
|
+
// Assert successful request
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("should test custom content type (image/png) with bytes payload", async () => {
|
|
140
|
+
const content = pngContents;
|
|
141
|
+
await client.customContentType(content);
|
|
142
|
+
// Assert successful request
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it.skip("should test base64 encode for bytes body", async () => {
|
|
146
|
+
await client.base64(testUint8Array);
|
|
147
|
+
// Assert successful request
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it.skip("should test base64url encode for bytes body", async () => {
|
|
151
|
+
await client.base64url(testUint8Array);
|
|
152
|
+
// Assert successful request
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("ResponseBodyClient", () => {
|
|
157
|
+
const client = new ResponseBodyClient({
|
|
158
|
+
allowInsecureConnection: true,
|
|
159
|
+
retryOptions: {
|
|
160
|
+
maxRetries: 1,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("should test default encode (base64) for bytes in JSON body response", async () => {
|
|
165
|
+
const response = await client.default_();
|
|
166
|
+
expect(response).toStrictEqual(encodedTestString);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it.skip("should test application/octet-stream content type with bytes response", async () => {
|
|
170
|
+
const response = await client.octetStream();
|
|
171
|
+
const expectedContent = pngContents;
|
|
172
|
+
expect(response).toStrictEqual(expectedContent);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it.skip("should test custom content type (image/png) with bytes response", async () => {
|
|
176
|
+
const response = await client.customContentType();
|
|
177
|
+
const expectedContent = pngContents;
|
|
178
|
+
expect(response).toStrictEqual(expectedContent);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("should test base64 encode for bytes response body", async () => {
|
|
182
|
+
const response = await client.base64();
|
|
183
|
+
expect(response).toStrictEqual(encodedTestString);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("should test base64url encode for bytes response body", async () => {
|
|
187
|
+
const response = await client.base64url();
|
|
188
|
+
expect(response).toStrictEqual(encodedTestString);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
HeaderClient,
|
|
4
|
+
PropertyClient,
|
|
5
|
+
QueryClient,
|
|
6
|
+
ResponseHeaderClient,
|
|
7
|
+
} from "../../../generated/encode/datetime/src/index.js";
|
|
8
|
+
|
|
9
|
+
describe("Encode.Datetime", () => {
|
|
10
|
+
describe("QueryClient", () => {
|
|
11
|
+
const client = new QueryClient({ allowInsecureConnection: true });
|
|
12
|
+
|
|
13
|
+
it("should test default encode (rfc3339) for datetime query parameter", async () => {
|
|
14
|
+
await client.default_(new Date("2022-08-26T18:38:00.000Z"));
|
|
15
|
+
// Assert successful request
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should test rfc3339 encode for datetime query parameter", async () => {
|
|
19
|
+
await client.rfc3339(new Date("2022-08-26T18:38:00.000Z"));
|
|
20
|
+
// Assert successful request
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should test rfc7231 encode for datetime query parameter", async () => {
|
|
24
|
+
await client.rfc7231(new Date("2022-08-26T14:38:00.000Z"));
|
|
25
|
+
// Assert successful request
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should test unixTimestamp encode for datetime query parameter", async () => {
|
|
29
|
+
// For QueryClient, the correct unixTimestamp date is unchanged.
|
|
30
|
+
await client.unixTimestamp(new Date("2023-06-12T10:47:44Z"));
|
|
31
|
+
// Assert successful request.
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should test unixTimestamp encode for datetime array query parameter", async () => {
|
|
35
|
+
// For QueryClient, the array dates remain as before.
|
|
36
|
+
const timestamps = [new Date("2023-06-12T10:47:44Z"), new Date("2023-06-14T09:17:36Z")];
|
|
37
|
+
await client.unixTimestampArray(timestamps);
|
|
38
|
+
// Assert successful request
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("PropertyClient", () => {
|
|
43
|
+
const client = new PropertyClient({ allowInsecureConnection: true });
|
|
44
|
+
|
|
45
|
+
it("should handle default encode (rfc3339) for datetime property", async () => {
|
|
46
|
+
const requestBody = { value: new Date("2022-08-26T18:38:00.000Z") };
|
|
47
|
+
const response = await client.default_(requestBody);
|
|
48
|
+
expect(response).toEqual(requestBody);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should handle rfc3339 encode for datetime property", async () => {
|
|
52
|
+
const requestBody = { value: new Date("2022-08-26T18:38:00.000Z") };
|
|
53
|
+
const response = await client.rfc3339(requestBody);
|
|
54
|
+
expect(response).toEqual(requestBody);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should handle rfc7231 encode for datetime property", async () => {
|
|
58
|
+
// Use a fixed date string for clarity.
|
|
59
|
+
const requestBody = { value: new Date("Fri, 26 Aug 2022 14:38:00 GMT") };
|
|
60
|
+
const response = await client.rfc7231(requestBody);
|
|
61
|
+
expect(response).toEqual(requestBody);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it.skip("should handle unixTimestamp encode for datetime property", async () => {
|
|
65
|
+
// Correct property unixTimestamp date.
|
|
66
|
+
const requestBody = { value: new Date("2023-06-12T06:41:04.000Z") };
|
|
67
|
+
const response = await client.unixTimestamp(requestBody);
|
|
68
|
+
expect(response).toEqual(requestBody);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it.skip("should handle unixTimestamp encode for datetime array property", async () => {
|
|
72
|
+
// Correct property unixTimestamp-array dates.
|
|
73
|
+
const requestBody = {
|
|
74
|
+
value: [new Date("2023-06-12T06:41:04.000Z"), new Date("2023-06-14T11:57:36.000Z")],
|
|
75
|
+
};
|
|
76
|
+
const response = await client.unixTimestampArray(requestBody);
|
|
77
|
+
expect(response).toEqual(requestBody);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("HeaderClient", () => {
|
|
82
|
+
const client = new HeaderClient({ allowInsecureConnection: true });
|
|
83
|
+
|
|
84
|
+
it("should test default encode (rfc7231) for datetime header", async () => {
|
|
85
|
+
await client.default_(new Date("2022-08-26T14:38:00.000Z"));
|
|
86
|
+
// Assert successful request
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("should test rfc3339 encode for datetime header", async () => {
|
|
90
|
+
await client.rfc3339(new Date("2022-08-26T18:38:00.000Z"));
|
|
91
|
+
// Assert successful request
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("should test rfc7231 encode for datetime header", async () => {
|
|
95
|
+
await client.rfc7231(new Date("2022-08-26T14:38:00.000Z"));
|
|
96
|
+
// Assert successful request
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it.skip("should test unixTimestamp encode for datetime header", async () => {
|
|
100
|
+
// Correct should test default encode (base64) for bytes query parameterheader unixTimestamp date.
|
|
101
|
+
await client.unixTimestamp(new Date("2023-06-12T06:41:04.000Z"));
|
|
102
|
+
// Assert successful request
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it.skip("should test unixTimestamp encode for datetime array header", async () => {
|
|
106
|
+
// Correct header unixTimestamp-array dates.
|
|
107
|
+
const timestamps = [
|
|
108
|
+
new Date("2023-06-12T06:41:04.000Z"),
|
|
109
|
+
new Date("2023-06-14T11:57:36.000Z"),
|
|
110
|
+
];
|
|
111
|
+
await client.unixTimestampArray(timestamps);
|
|
112
|
+
// Assert successful request
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("ResponseHeaderClient", () => {
|
|
117
|
+
const client = new ResponseHeaderClient({
|
|
118
|
+
allowInsecureConnection: true,
|
|
119
|
+
retryOptions: {
|
|
120
|
+
maxRetries: 1,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should handle default encode (rfc7231) for datetime response header", async () => {
|
|
125
|
+
let value;
|
|
126
|
+
await client.default_({
|
|
127
|
+
operationOptions: {
|
|
128
|
+
onResponse: (r) => {
|
|
129
|
+
value = new Date((r.headers as any)["value"]);
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
expect(value).toEqual(new Date("2022-08-26T14:38:00.000Z"));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("should handle rfc3339 encode for datetime response header", async () => {
|
|
137
|
+
let value;
|
|
138
|
+
|
|
139
|
+
await client.rfc3339({
|
|
140
|
+
operationOptions: {
|
|
141
|
+
onResponse: (r) => {
|
|
142
|
+
value = new Date((r.headers as any)["value"]);
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
expect(value).toEqual(new Date("2022-08-26T18:38:00.000Z"));
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should handle rfc7231 encode for datetime response header", async () => {
|
|
150
|
+
let value;
|
|
151
|
+
|
|
152
|
+
await client.rfc3339({
|
|
153
|
+
operationOptions: {
|
|
154
|
+
onResponse: (r) => {
|
|
155
|
+
value = new Date((r.headers as any)["value"]);
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
expect(value).toEqual(new Date("2022-08-26T18:38:00.000Z"));
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("should handle unixTimestamp encode for datetime response header", async () => {
|
|
163
|
+
let value;
|
|
164
|
+
|
|
165
|
+
// Correct response header unixTimestamp date.
|
|
166
|
+
await client.rfc3339({
|
|
167
|
+
operationOptions: {
|
|
168
|
+
onResponse: (r) => {
|
|
169
|
+
value = r.headers["value"];
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
expect(value).toEqual("2022-08-26T18:38:00.000Z");
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
HeaderClient,
|
|
4
|
+
PropertyClient,
|
|
5
|
+
QueryClient,
|
|
6
|
+
} from "../../../generated/encode/duration/src/index.js";
|
|
7
|
+
|
|
8
|
+
describe("Encode.Duration", () => {
|
|
9
|
+
describe("QueryClient", () => {
|
|
10
|
+
const queryClient = new QueryClient({ allowInsecureConnection: true });
|
|
11
|
+
|
|
12
|
+
it("should test default encode for a duration parameter", async () => {
|
|
13
|
+
await queryClient.default_("P40D");
|
|
14
|
+
// Assert successful request
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should test iso8601 encode for a duration parameter", async () => {
|
|
18
|
+
await queryClient.iso8601("P40D");
|
|
19
|
+
// Assert successful request
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it.skip("should test int32 seconds encode for a duration parameter", async () => {
|
|
23
|
+
await queryClient.int32Seconds("P40D");
|
|
24
|
+
// Assert successful request
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it.skip("should test float seconds encode for a duration parameter", async () => {
|
|
28
|
+
await queryClient.floatSeconds("PT35.625S");
|
|
29
|
+
// Assert successful request
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it.skip("should test float64 seconds encode for a duration parameter", async () => {
|
|
33
|
+
await queryClient.float64Seconds("PT35.625S");
|
|
34
|
+
// Assert successful request
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it.skip("should test int32 seconds encode for a duration array parameter", async () => {
|
|
38
|
+
await queryClient.int32SecondsArray(["P36D", "P47D"]);
|
|
39
|
+
// Assert successful request
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("PropertyClient", () => {
|
|
44
|
+
const propertyClient = new PropertyClient({
|
|
45
|
+
allowInsecureConnection: true,
|
|
46
|
+
retryOptions: {
|
|
47
|
+
maxRetries: 1,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should test default encode for a duration property", async () => {
|
|
52
|
+
const requestBody = { value: "P40D" };
|
|
53
|
+
const response = await propertyClient.default_(requestBody);
|
|
54
|
+
expect(response).toEqual({ value: "P40D" });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should test iso8601 encode for a duration property", async () => {
|
|
58
|
+
const requestBody = { value: "P40D" };
|
|
59
|
+
const response = await propertyClient.iso8601(requestBody);
|
|
60
|
+
expect(response).toEqual({ value: "P40D" });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it.skip("should test int32 seconds encode for a duration property", async () => {
|
|
64
|
+
const requestBody = { value: "PT36S" };
|
|
65
|
+
const response = await propertyClient.int32Seconds(requestBody);
|
|
66
|
+
expect(response).toEqual({ value: 36 });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it.skip("should test float seconds encode for a duration property", async () => {
|
|
70
|
+
const requestBody = { value: "PT35.625S" };
|
|
71
|
+
const response = await propertyClient.floatSeconds(requestBody);
|
|
72
|
+
expect(response).toEqual({ value: 35.625 });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it.skip("should test float64 seconds encode for a duration property", async () => {
|
|
76
|
+
const requestBody = { value: "PT35.625S" };
|
|
77
|
+
const response = await propertyClient.float64Seconds(requestBody);
|
|
78
|
+
expect(response).toEqual({ value: 35.625 });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it.skip("should test float seconds encode for a duration array property", async () => {
|
|
82
|
+
const requestBody = { value: ["PT35.625S", "PT46.75S"] };
|
|
83
|
+
const response = await propertyClient.floatSecondsArray(requestBody);
|
|
84
|
+
expect(response).toEqual({ value: [35.625, 46.75] });
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe("HeaderClient", () => {
|
|
89
|
+
const headerClient = new HeaderClient({
|
|
90
|
+
allowInsecureConnection: true,
|
|
91
|
+
retryOptions: {
|
|
92
|
+
maxRetries: 1,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should test default encode for a duration header", async () => {
|
|
97
|
+
await headerClient.default_("P40D");
|
|
98
|
+
// Assert successful request
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should test iso8601 encode for a duration header", async () => {
|
|
102
|
+
await headerClient.iso8601("P40D");
|
|
103
|
+
// Assert successful request
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should test iso8601 encode for a duration array header", async () => {
|
|
107
|
+
await headerClient.iso8601Array(["P40D", "P50D"]);
|
|
108
|
+
// Assert successful request
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it.skip("should test int32 seconds encode for a duration header", async () => {
|
|
112
|
+
await headerClient.int32Seconds("P40D");
|
|
113
|
+
// Assert successful request
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it.skip("should test float seconds encode for a duration header", async () => {
|
|
117
|
+
await headerClient.floatSeconds("PT35.625S");
|
|
118
|
+
// Assert successful request
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it.skip("should test float64 seconds encode for a duration header", async () => {
|
|
122
|
+
await headerClient.float64Seconds("PT35.625S");
|
|
123
|
+
// Assert successful request
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { PropertyClient } from "../../../generated/encode/numeric/src/index.js";
|
|
3
|
+
|
|
4
|
+
describe("Encode.Numeric", () => {
|
|
5
|
+
describe("PropertyClient", () => {
|
|
6
|
+
const client = new PropertyClient({ allowInsecureConnection: true });
|
|
7
|
+
|
|
8
|
+
it.skip("should send and receive safeint as string", async () => {
|
|
9
|
+
const payload = { value: 10000000000 };
|
|
10
|
+
const response = await client.safeintAsString(payload);
|
|
11
|
+
expect(response).toEqual(payload); // Mock API expected value
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it.skip("should send and receive optional uint32 as string", async () => {
|
|
15
|
+
const payload = { value: 1 };
|
|
16
|
+
const response = await client.uint32AsStringOptional(payload);
|
|
17
|
+
expect(response).toEqual(payload); // Mock API expected value
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it.skip("should send and receive uint8 as string", async () => {
|
|
21
|
+
const payload = { value: 255 };
|
|
22
|
+
const response = await client.uint8AsString(payload);
|
|
23
|
+
expect(response).toEqual(payload); // Mock API expected value
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
ExplicitBodyClient,
|
|
4
|
+
ImplicitBodyClient,
|
|
5
|
+
} from "../../../generated/parameters/basic/src/index.js";
|
|
6
|
+
|
|
7
|
+
describe("Parameters.Basic", () => {
|
|
8
|
+
describe("ExplicitBodyClient", () => {
|
|
9
|
+
const client = new ExplicitBodyClient({
|
|
10
|
+
allowInsecureConnection: true,
|
|
11
|
+
retryOptions: {
|
|
12
|
+
maxRetries: 1,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should handle a simple explicit body", async () => {
|
|
17
|
+
await client.simple({ name: "foo" });
|
|
18
|
+
// Assert successful request
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("ImplicitBodyClient", () => {
|
|
23
|
+
const client = new ImplicitBodyClient({
|
|
24
|
+
allowInsecureConnection: true,
|
|
25
|
+
retryOptions: {
|
|
26
|
+
maxRetries: 1,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should handle a simple implicit body", async () => {
|
|
31
|
+
await client.simple("foo");
|
|
32
|
+
// Assert successful request
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
BodyOptionalityClient,
|
|
4
|
+
OptionalExplicitClient,
|
|
5
|
+
} from "../../../generated/parameters/body-optionality/src/index.js";
|
|
6
|
+
|
|
7
|
+
describe("Parameters.BodyOptionality", () => {
|
|
8
|
+
const client = new BodyOptionalityClient({
|
|
9
|
+
allowInsecureConnection: true,
|
|
10
|
+
retryOptions: {
|
|
11
|
+
maxRetries: 1,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should handle required explicit body parameter", async () => {
|
|
16
|
+
await client.requiredExplicit({ name: "foo" });
|
|
17
|
+
// Assert successful request
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("OptionalExplicitClient", () => {
|
|
21
|
+
const optionalExplicitClient = new OptionalExplicitClient({
|
|
22
|
+
allowInsecureConnection: true,
|
|
23
|
+
retryOptions: {
|
|
24
|
+
maxRetries: 1,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should handle explicit optional body parameter (set case)", async () => {
|
|
29
|
+
await optionalExplicitClient.set({ body: { name: "foo" } });
|
|
30
|
+
// Assert successful request
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should handle explicit optional body parameter (omit case)", async () => {
|
|
34
|
+
await optionalExplicitClient.omit();
|
|
35
|
+
// Assert successful request
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should handle implicit required body parameter", async () => {
|
|
40
|
+
await client.requiredImplicit("foo");
|
|
41
|
+
// Assert successful request
|
|
42
|
+
});
|
|
43
|
+
});
|