fix https://github.com/microsoft/typespec/issues/3291
Changes:
1. Figure out the most accurate location for the diagnostic
2. If diagnostic target a child node of the base diagnostic target then
emit diagnostic directly there
3. Otherwise emit back at the root(or closest child node) and build
stack of error message
Example the following would now emit the error on a
```ts
const b = #{ prop: #{a: "abc"}};
const a: {prop: {}} = b;
```
```
Type '{ prop: { a: "abc" } }' is not assignable to type '{ prop: {} }'
Type '{ a: "abc" }' is not assignable to type '{}'
Object value may only specify known properties, and 'a' does not exist in type '{}'.
```
Previously the error would have been in the complete wrong place
<img width="271" alt="image"
src="https://github.com/user-attachments/assets/c403d1ec-3611-4ad6-87b0-2e0a075dc1c5">
Fixes https://github.com/Azure/autorest.csharp/issues/4715
This PR changes the property names for models and enums in the
`tspCodeModel.json` to be lower cases to align convention and the type
definitions in TCGC.
clients and operations are untouched in this PR, we could make follow up
on those later.
History: we originally intend to use m4 prenamer (opt-in via
flag/option) to keep names in SDK same as from Swagger (mostly for
brownfield).
But later we decided to just use `@clientName` in client.tsp to
explicitly do the naming, if backward-compatibility is an issue.
This flag/option is not used by any service.
The type relation logic is already quite sizable and isn't really tied
to the checker too much.
Apart from accessing std types it can be self contained. This should
help maintaining it.
Fixes#4256Fixes#4261
In order to get our mocking system working properly and make everything
aligned, I changed the `SourceInputModel` to public and added it to the
`CodeModelPlugin` so that our plugin writers could override something on
it to do some advanced stuffs
Ideally we can connect that to api view to report changes to the api
without having to commit extra files to the repo.
But for now this at least enforce the good pattern for api extractor
This PR cleans up some of the build steps that are not required. Latest
JDK LTS version (Java 21) is pre-installed in 1es hosts and we don't
need to explicitly download and install this. So, this PR comments out
the code that does this as we might still need this in the future to
install newer versions of Java that are not available on 1es.
- set the attribute value via encodedName
- set the value on scalar via encodedName
- emit error if missing the 2nd argument
---------
Co-authored-by: Kyle Zhang <v-zhanh@microsoft.com>
Fixes https://github.com/microsoft/typespec/issues/4152
Depends on https://github.com/microsoft/typespec/pull/4216
This PR updates how tsp-openapi3 handles generating models for schemas
that use `allOf`.
Currently `allOf` is ignored unless there is only 1 member and that
member is a schema reference. In this scenario, the model extends the
single member.
This update now takes all of the schema `allOf` members into
consideration when generating a model.
- inline-schemas have their properties merged into the model's
properties
- schema references without a discriminator defined are spread into the
model
- if only 1 schema reference contains a discriminator, then the model
extends it, otherwise these schema references are spread as well.
---------
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
Fixes#4151
This PR updates tsp-openapi3's model generation so that all top-level
parameters (`#/components/parameters`) are nested in a `Parameters`
block namespace.
Prior to this change, if top-level parameter had the same name as a
top-level schema, we would attempt to merge the two. This worked OK if
the schema was an object type, but led to broken results if the schema
was anything else.
Note:
In the linked issue, it was suggested that top-level schemas not be
scoped to their own namespace, so if a schema is referenced by a
parameter, it will now qualify it with the file-level namespace. This PR
introduces a `context` object that contains some state that can be
passed around. This is useful for keeping track of the file-level
namespace and using it when necessary, but the context will also be
useful in cases where we need to look at the definition of a referenced
schema from another schema.
---------
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.7
to 4.0.8.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/micromatch/micromatch/blob/4.0.8/CHANGELOG.md">micromatch's
changelog</a>.</em></p>
<blockquote>
<h2>[4.0.8] - 2024-08-22</h2>
<ul>
<li>backported CVE-2024-4067 fix (from v4.0.6) over to 4.x branch</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8bd704ec0d"><code>8bd704e</code></a>
4.0.8</li>
<li><a
href="a0e68416a4"><code>a0e6841</code></a>
run verb to generate README documentation</li>
<li><a
href="4ec288484f"><code>4ec2884</code></a>
Merge branch 'v4' into hauserkristof-feature/v4.0.8</li>
<li><a
href="03aa805217"><code>03aa805</code></a>
Merge pull request <a
href="https://redirect.github.com/micromatch/micromatch/issues/266">#266</a>
from hauserkristof/feature/v4.0.8</li>
<li><a
href="814f5f70ef"><code>814f5f7</code></a>
lint</li>
<li><a
href="67fcce6a10"><code>67fcce6</code></a>
fix: CHANGELOG about braces & CVE-2024-4068, v4.0.5</li>
<li><a
href="113f2e3fa7"><code>113f2e3</code></a>
fix: CVE numbers in CHANGELOG</li>
<li><a
href="d9dbd9a266"><code>d9dbd9a</code></a>
feat: updated CHANGELOG</li>
<li><a
href="2ab13157f4"><code>2ab1315</code></a>
fix: use actions/setup-node@v4</li>
<li><a
href="1406ea38f3"><code>1406ea3</code></a>
feat: rework test to work on macos with node 10,12 and 14</li>
<li>Additional commits viewable in <a
href="https://github.com/micromatch/micromatch/compare/4.0.7...4.0.8">compare
view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=micromatch&package-manager=npm_and_yarn&previous-version=4.0.7&new-version=4.0.8)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
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)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/microsoft/typespec/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
add some new cases
1. @oneOf decorator can only be used on a union.
2. throws diagnostics for null enum definitions
---------
Co-authored-by: Kyle Zhang <v-zhanh@microsoft.com>
OpenAPI 3 Emitter crash on @useAuth({}).
seems the diagnostics is not initial before add item.
fix: https://github.com/microsoft/typespec/issues/4097
---------
Co-authored-by: Kyle Zhang <v-zhanh@microsoft.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
Co-authored-by: Christopher Radek <14189820+chrisradek@users.noreply.github.com>
- add `SerializationFormat.String` to indicate a mandatory serialization
to string
- update clientmodel to add int-to-string serialization/deserialization
- update test case
- add test helper
part of https://github.com/Azure/autorest.csharp/issues/4919
---------
Co-authored-by: Mingzhe Huang (from Dev Box) <mingzhehuang@microsoft.com>
Fix https://github.com/microsoft/typespec/issues/4205
Fixes https://github.com/microsoft/typespec/issues/3973
Problem to solve:
When any type except string (e.g. int, TimeSpan and so on) as
header/query, it is not correct covert to correct format, and when there
is an array as header/query, it does not serialize correct in connection
format (such as cvs, pipe and so on).
- call TypeFormatters.ConvertToString to covert this type to correct
format
- when it is an array, we need to convert to string in correct
collection format.