Граф коммитов

2522 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin f4c8710673
Fix set response doc when an envelope (#4322)
fix [#3664](https://github.com/microsoft/typespec/issues/3664)
2024-09-06 23:45:59 +00:00
Timothee Guerin d2ac995842
Extract source resolution logic into its own source loader (#4324)
This will allow other tools to be able to reuse the typespec compiler
source resolution logic(Figure out all the imported files) without doing
a full compile and cleans up the program.ts which is doing a lot of
things.

Usage

```ts
const loader = createSourceLoader(host);

loader.importFile(resolvePath(cwd, "main.tsp", {type: "project"}));

loader.importPath("./foo.tsp", NoTarget, cwd, {type: "project"} );

loader.resolution.sourceFiles // Tsp source files loaded
loader.resolution.jsSourceFiles // Js source file loaded
```
2024-09-06 23:24:59 +00:00
Timothee Guerin dde8dc0ca7
Add api extractor for openapi package and fix issues (#4354) 2024-09-06 23:18:53 +00:00
JoshLove-msft 86cc361bf0
Add tests for changing property type/accessibility (#4365)
Validates that https://github.com/microsoft/typespec/issues/4258 and
https://github.com/microsoft/typespec/issues/4265 are fixed. They were
fixed by https://github.com/microsoft/typespec/pull/4362.
2024-09-06 22:56:05 +00:00
JoshLove-msft 782dca54ed
Support customizing property names (#4362)
Fixes https://github.com/microsoft/typespec/issues/4257
2024-09-06 21:35:58 +00:00
Timothee Guerin 03d4fca5c0
Improvements to type relation errors (#4357)
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">
2024-09-06 21:07:18 +00:00
Dapeng Zhang 89e19ef521
Change the property names to be lower case letter in the tspCodeModel.json (#4331)
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.
2024-09-06 07:32:45 +00:00
Weidong Xu d836c427be
http-client-java, sync code from autorest.java (#4345)
sync https://github.com/Azure/autorest.java/pull/2936
change to JavaSettings,java is already included in prior sync PR.

This should be the last PR we need to sync.
2024-09-06 06:33:29 +00:00
Weidong Xu 7219aa4035
http-client-java, update cadl-ranch, handle TCGC multipart logic (#4352)
pending issue at https://github.com/Azure/typespec-azure/issues/1488
2024-09-06 06:04:23 +00:00
Srikanta f329e038f8
Java codegen: disable dependency transfer logging (#4355)
Maven build logs all dependency transfers and is too verbose. This PR
disables dependency transfer logging to keep the pipeline logs clean.
2024-09-06 02:07:51 +00:00
Timothee Guerin 1c2154cbda
Fix anonymous union variant in tree viewer (#4353)
fix https://github.com/Azure/typespec-azure/issues/1480
2024-09-05 17:45:19 +00:00
Dapeng Zhang ad635d920e
Align the structure of model property (#4319)
Fixes https://github.com/Azure/autorest.csharp/issues/4793
2024-09-05 06:20:02 +00:00
m-nash 06c0bb5dca
Handle replacement properties (#4325)
Supports https://github.com/microsoft/typespec/issues/3981

These cadl ranch tests have models which use replacement properties in
extended types that we need to handle.
2024-09-05 02:12:37 +00:00
Xiaofei Cao 93377fd7dd
java generator, fix generator-test when running from main (#4334)
- Part of https://github.com/microsoft/typespec/pull/4315, though before
TypeSpec ARM fix, we'll probably will not merge that PR
2024-09-05 01:57:34 +00:00
JoshLove-msft 244dbc08c0
Use the Cat model in tests (#4341)
Fix to https://github.com/microsoft/typespec/pull/4301. The PR was
updated to always keep Union models, so we don't need the reflection
workaround.
2024-09-04 23:43:54 +00:00
Weidong Xu b645fb3d6d
http-client-java, remove unused namer module (#4328)
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.
2024-09-04 23:12:53 +00:00
JoshLove-msft 1dcd5c4c36
Prune unreferenced files (#4301)
Fixes https://github.com/microsoft/typespec/issues/4218

Replaces https://github.com/microsoft/typespec/pull/4288
2024-09-04 22:25:36 +00:00
Timothee Guerin 12ccdd1818
Refactor: Separate type relation logic from checker.ts (#4337)
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.
2024-09-04 22:01:36 +00:00
Dapeng Zhang cd6e362df8
implement the feature of changing the name of a model (#4285)
Fixes #4256 
Fixes #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
2024-09-04 21:24:41 +00:00
Timothee Guerin 04b198693d
Setup api extractor for xml library (#4335)
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
2024-09-04 21:12:36 +00:00
Timothee Guerin 74627ec770
Fix labels CI (#4336)
Seems like that was merged with conflict or failure
2024-09-04 17:58:53 +00:00
Wei Hu eacbc248f8
Remove extra space to fix VS debug attachment (#4333)
Resolves https://github.com/microsoft/typespec/issues/4332

extra space in argument for `child_process.spawn` ended up into missing
2024-09-04 09:23:17 +00:00
Srikanta 0f8dcf4ea0
Remove unused test directory (#4318) 2024-09-04 02:06:37 +00:00
Srikanta 73e61f9202
Java codegen - clean up build steps (#4323)
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.
2024-09-04 02:03:41 +00:00
Kyle Zhang 663d057c08
add test cases for Xml lib (#4306)
- 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>
2024-09-03 11:50:56 +00:00
Dapeng Zhang a5546cafea
fix the response map issue in the emitter (#4307)
Fixes https://github.com/Azure/autorest.csharp/issues/5027
2024-09-03 08:42:31 +00:00
Weidong Xu bc1c599517
Java sync to 16e2939c38dec8bb5322214d1a99f2c44284a2bf (#4293)
I didn't include https://github.com/Azure/autorest.java/pull/2936

I will remove prenamer in next PR.
2024-09-03 08:22:21 +00:00
Srikanta c7ed92edbb
Java codegen: Run cadl ranch tests (#4303)
This PR enables starting the test server and running the Java tests
against the server.
2024-09-03 07:18:57 +00:00
Pan Shao 11a01ce1dc
Read AllowReserved value (#4294)
Fix https://github.com/Azure/autorest.csharp/issues/4966

---------

Co-authored-by: Pan Shao <pashao@microsoft.com>
2024-09-03 02:15:54 +00:00
Crystal YU c2b80f79c7
support enum discrimintor (#4279)
Fix https://github.com/microsoft/typespec/issues/4002

- implement inheritance with enum discriminator
- onboard http\type\model\inheritance\emum-discriminator cadl-ranch test
project
2024-09-02 02:31:53 +00:00
Timothee Guerin 8635849242
Fix: Validating cross namespace (#4304) 2024-08-29 22:37:04 +00:00
Christopher Radek 2278c42581
tsp-openapi3 - improve model generation of schemas using allOf (#4232)
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>
2024-08-29 21:54:45 +00:00
Christopher Radek 5a75506953
tsp-openapi3 - scope top-level parameters to Parameters namespace (#4216)
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>
2024-08-29 18:55:59 +00:00
Timothee Guerin 1b659ad8c5
Do not mutate type stack (#4299) 2024-08-29 17:36:08 +00:00
dependabot[bot] 2e6cd73b23
Bump micromatch from 4.0.7 to 4.0.8 in /packages/http-client-java (#4250)
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 &amp; 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>
2024-08-29 17:02:20 +00:00
Timothee Guerin 06da57d4c4
Fix regression in validation of operation params versioning not taking operation availability into account (#4297) 2024-08-29 16:26:35 +00:00
Timothee Guerin 133321f9c0
Add validation to make sure operation params reference models available in the current version (#4179)
fix [#3920](https://github.com/microsoft/typespec/issues/3920)
fix [#3134](https://github.com/microsoft/typespec/issues/3134)
2024-08-29 13:25:14 +00:00
Kyle Zhang 302e0c7c08
new test cases for openAPI 3.0 (#4195)
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>
2024-08-29 12:48:31 +00:00
Timothee Guerin a45f2cc4a3
Stop json schema from crashing on unknown scalar (#4150)
fix #4096
2024-08-29 12:44:54 +00:00
Kyle Zhang 92684d90e2
Fix Bug for OpenAPI 3 Emitter crash on @useAuth({}) (#4133)
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>
2024-08-27 23:57:42 +00:00
Jorge Rangel 21736711f3
Add support for additional props model property in models (#4277)
Contributes to https://github.com/microsoft/typespec/issues/4007. The
serialization changes will be included in follow up PR(s).
2024-08-27 21:28:26 +00:00
Srikanta 7600a2bb58
Java Http client generator: generate tests (#4251) 2024-08-27 07:31:07 +00:00
Allen Zhang 9e37021186
Accessibility, increase playground footer contrast (#4276) 2024-08-26 20:23:04 +00:00
ShivangiReja fc1a6c3d88
Adopt http\type\property\value-types from cadl ranch (#4273)
Fixes: https://github.com/microsoft/typespec/issues/4010

---------

Co-authored-by: ShivangiReja <shivangi.reja@microsoft.com>
2024-08-26 20:07:00 +00:00
Mario Guerra 8dfacdb08e
minor edits and corrections (#4183) 2024-08-26 18:48:34 +00:00
Mingzhe Huang e6040ed56a
feat(http-client-csharp): `@encode(string)` support for int types (#4186)
- 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>
2024-08-26 07:12:42 +00:00
m-nash b4005cdcbb
adopt http/type/property/optionality (#4267)
Fixes https://github.com/microsoft/typespec/issues/4009
2024-08-26 05:06:43 +00:00
m-nash b27efa97c4
Add support for discriminated models (#4253)
Fixes https://github.com/microsoft/typespec/issues/4006
Fixes https://github.com/microsoft/typespec/issues/3500
2024-08-26 03:57:46 +00:00
ShivangiReja 142f44fa23
Adopt http\encode\datetime from cadl ranch (#4252)
Fixes: https://github.com/microsoft/typespec/issues/3972

---------

Co-authored-by: ShivangiReja <shivangi.reja@microsoft.com>
2024-08-23 23:38:32 +00:00
Crystal YU d932462149
implement array as header and query, and format different type to string (#4213)
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.
2024-08-23 18:34:16 +00:00