Skip to content

Commit

Permalink
Bump core from edf272d to 72d544c (#1275)
Browse files Browse the repository at this point in the history
Bumps [core](https://github.com/microsoft/typespec) from `edf272d` to
`72d544c`.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/microsoft/typespec/commit/72d544c1eae2339401b3e9bfdd8aedd1b843326d"><code>72d544c</code></a>
feat(http-client-csharp): adopt TCGC getAllOperations (<a
href="https://github.com/microsoft/typespec/issues/3867">#3867</a>)</li>
<li><a
href="https://github.com/microsoft/typespec/commit/12a8ddbe1580f8f6397873c822d33390e9b1d943"><code>12a8ddb</code></a>
Capture full coverage of cadl ranch in ci (<a
href="https://github.com/microsoft/typespec/issues/4054">#4054</a>)</li>
<li><a
href="https://github.com/microsoft/typespec/commit/1d43455d2873df6bae930ed210d8c61ff90206cb"><code>1d43455</code></a>
Move ToSerial and ToEnum to SerializationProviders (<a
href="https://github.com/microsoft/typespec/issues/3795">#3795</a>)</li>
<li><a
href="https://github.com/microsoft/typespec/commit/5a8b2ccda4be044af1d438e9d8e469c7d26162d6"><code>5a8b2cc</code></a>
Keep watch going when crash happens (<a
href="https://github.com/microsoft/typespec/issues/4022">#4022</a>)</li>
<li><a
href="https://github.com/microsoft/typespec/commit/44fc030f8ddc8ae8956a0ba05726dd0048e623eb"><code>44fc030</code></a>
Add support for encoding numeric types as string (<a
href="https://github.com/microsoft/typespec/issues/4020">#4020</a>)</li>
<li><a
href="https://github.com/microsoft/typespec/commit/44ffaf7e184a4e5a007c086a8feb6e2088c9da40"><code>44ffaf7</code></a>
Fix HttpPart not respecting part name (<a
href="https://github.com/microsoft/typespec/issues/3909">#3909</a>)</li>
<li><a
href="https://github.com/microsoft/typespec/commit/da41e74c17d6b551d90b9d22c3c52a6a7d284176"><code>da41e74</code></a>
pet store rewrite (<a
href="https://github.com/microsoft/typespec/issues/3958">#3958</a>)</li>
<li>See full diff in <a
href="https://github.com/microsoft/typespec/compare/edf272da71ab47e953201ceab10b78466484b06f...72d544c1eae2339401b3e9bfdd8aedd1b843326d">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Timothee Guerin <[email protected]>
  • Loading branch information
dependabot[bot] and timotheeguerin committed Aug 1, 2024
1 parent 8f005c0 commit 98a5046
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-autorest"
---

Add support for encoding numeric types as string
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-azure-core"
---

2 changes: 1 addition & 1 deletion core
Submodule core updated 159 files
8 changes: 4 additions & 4 deletions packages/typespec-autorest/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2180,12 +2180,12 @@ export async function getOpenAPIForService(
}
function mergeFormatAndEncoding(
format: string | undefined,
encoding: string,
encoding: string | undefined,
encodeAsFormat: string | undefined
): string {
): string | undefined {
switch (format) {
case undefined:
return encodeAsFormat ?? encoding;
return encodeAsFormat ?? encoding ?? format;
case "date-time":
switch (encoding) {
case "rfc3339":
Expand All @@ -2205,7 +2205,7 @@ export async function getOpenAPIForService(
return encodeAsFormat ?? encoding;
}
default:
return encodeAsFormat ?? encoding;
return encodeAsFormat ?? encoding ?? format;
}
}

Expand Down
23 changes: 21 additions & 2 deletions packages/typespec-autorest/test/primitive-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,16 @@ describe("typespec-autorest: primitives", () => {
async function testEncode(
scalar: string,
expectedOpenApi: OpenAPI2Schema,
encoding?: string,
encoding?: string | null,
encodeAs?: string
) {
const encodeAsParam = encodeAs ? `, ${encodeAs}` : "";
const encodeDecorator = encoding ? `@encode("${encoding}"${encodeAsParam})` : "";
const encodeDecorator =
encoding === null
? `@encode(${encodeAs})`
: encoding !== undefined
? `@encode("${encoding}"${encodeAsParam})`
: "";
const res1 = await oapiForModel("s", `${encodeDecorator} scalar s extends ${scalar};`);
deepStrictEqual(res1.defs.s, expectedOpenApi);
const res2 = await oapiForModel("Test", `model Test {${encodeDecorator} prop: ${scalar}};`);
Expand Down Expand Up @@ -287,5 +292,19 @@ describe("typespec-autorest: primitives", () => {
it("set format to base64url when encoding bytes as base64url", () =>
testEncode("bytes", { type: "string", format: "base64url" }, "base64url"));
});

describe("int64", () => {
it("set type: integer and format to 'int64' by default", () =>
testEncode("int64", { type: "integer", format: "int64" }));
it("set type: string and format to int64 when @encode(string)", () =>
testEncode("int64", { type: "string", format: "int64" }, null, "string"));
});

describe("decimal128", () => {
it("set type: integer and format to 'int64' by default", () =>
testEncode("decimal128", { type: "number", format: "decimal" }));
it("set type: string and format to int64 when @encode(string)", () =>
testEncode("decimal128", { type: "string", format: "decimal" }, null, "string"));
});
});
});
2 changes: 1 addition & 1 deletion packages/typespec-azure-core/src/rules/known-encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const knownEncodingRule = createRule({
create(context) {
function checkEncoding(type: ModelProperty | Scalar) {
const encode = getEncode(context.program, type);
if (encode) {
if (encode && encode.encoding) {
if (!knownEncodings.has(encode.encoding)) {
context.reportDiagnostic({
format: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ describe("typespec-client-generator-core: general decorators list", () => {
strictEqual(models.length, 1);
strictEqual(models[0].properties[0].decorators[0].name, "TypeSpec.@encode");
const encodeInfo = models[0].properties[0].decorators[0].arguments[
"encoding"
"encodingOrEncodeAs"
] as SdkEnumValueType;
strictEqual(encodeInfo.value, "base64url");
strictEqual((encodeInfo.value as any).value, "base64url");
expectDiagnostics(runner.context.diagnostics, []);
});

Expand Down
49 changes: 49 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98a5046

Please sign in to comment.