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

64 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin 2f53533d94
Bump versions for release 0.55.0 - april 2024 (#3096) 2024-04-02 14:55:47 -07:00
Timothee Guerin 63cb176500
Deprecate known values (#3094)
fix #3009

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-04-02 19:37:27 +00:00
Timothee Guerin 29aa4a5ec4
Add release notes release 0.55 - April 2024 (#3093)
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-04-02 19:13:46 +00:00
Timothee Guerin d4823c089b
Fix swagger ui build (#3091)
Missed that when doing the PR, the default import tries to load the
`path` library, recommendation is just to import the right bundle
directly.
2024-04-02 09:33:15 -07:00
Timothee Guerin c6506bcdee
Fix: Literal unions with the same variants keep adding duplicate entries (#3090)
fix #3087
2024-04-02 01:21:29 +00:00
Timothee Guerin cda7ccf4d9
Playground: Migrate from swagger-ui-react to swagger-ui-dist (#3089)
swagger-ui-react pull in all the swagger ui dependencies which is a bit
anyoing as they are mostly optional and with pnpm requires you to build
native dependencies.
2024-04-01 17:13:08 -07:00
Timothee Guerin 5ba95d0371
Allow reload of js files in vitest (#3086)
Setup a workaround for the fact that vitest(vite underneath) doesn't
ever want to reload files in the outDir
https://github.com/vitest-dev/vitest/issues/5429

as the outDir isn't actually used in vitest(as far as I understand) this
is just an ok workaround.
2024-04-01 17:54:38 +00:00
Timothee Guerin 0dea649cd7
Update dependencies to resolve vulnerabilities and license issue (#3081)
- Remove unused rollup-plugin-dts dep that had problematic license
- Update dependencies to fix vulnerabilies
2024-03-29 21:22:06 +00:00
Timothee Guerin 6d54aeb4aa
Do not crash if hitting a unsupported intrinsic type (#3077)
fix #3073

This still doesn't provide an optimal experience as the error shows up
on the void type instead of where it is referenced but solving that is
that long standing issue about tracing back where an error should be
2024-03-28 20:29:33 +00:00
Timothee Guerin 85fa7aecec
Union template declaration were being finished in projector (#3052)
fix [#2946](https://github.com/microsoft/typespec/issues/2946)

Problem was that in the projector were were calling to this helper to
see if that was a type that we should finish but it was missing the
union case causing union template declaration from being finished in the
projector and then being shown as finished type in the semantic
navigator and crashing openapi3 emitter.
2024-03-28 20:08:30 +00:00
Timothee Guerin ce9c567e5b
Improve TM language for enums, unions and escaped identifiers (#3069)
resolves https://github.com/microsoft/typespec/issues/3070
The tm language wasn't correctly defining the syntax for escaped
identifiers

```
`North West`
```


Enums and unions syntax was also not very accurate and didn't tokenize
everything correctly


## Example of issue before


![image](https://github.com/microsoft/typespec/assets/1031227/ee60f4fe-5eef-4f86-baa5-1cc96b665526)

## After

![image](https://github.com/microsoft/typespec/assets/1031227/38405f18-0fa4-44ba-82f6-594bcd4fcebf)
2024-03-27 10:12:29 -07:00
Timothee Guerin 32e45d4da2
Add support for scalar in versioning (#3053)
fix [#3001](https://github.com/microsoft/typespec/issues/3001)
2024-03-26 23:43:37 +00:00
Timothee Guerin 4c34e78747
Fix visibility conflict with base models (#3049)
fix #2922
fix #3048(dup)
2024-03-25 18:56:55 +00:00
Timothee Guerin 095c7dd8d4
OpenAPI3: Fix multipart union part conflict (#3050)
Problem is that was now trying to create a new declaration for a named
union if it was used in multipart and json even though they were the
same
2024-03-25 18:13:26 +00:00
Timothee Guerin 39ee11bc46
Fix: OpenAPI3 not marking part of bytes or something else as `format: binary` (#3013)
fix [#2924](https://github.com/microsoft/typespec/issues/2924)

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-03-22 20:45:10 +00:00
Timothee Guerin 72bed4daf8
More reliable codefix application (#3041)
Current approach was getting in all kind of conflict because it was
calling getCodeActions too much and we were clearing the cached id
2024-03-22 17:44:47 +00:00
Timothee Guerin 4e6f137c65
Emit `{nulable: true}` when trying to emit `null` in openapi3 (#2967)
fix #2217

This isn't fully accurate as it is saying in openapi3 that it can be
anything and `null` but this solve a crash, we could consider adding a
warning

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-03-22 16:53:54 +00:00
Timothee Guerin 8839ae173f
Fix policy include private package that doesn't get versioned (#2990) 2024-03-22 04:16:00 +00:00
Timothee Guerin e0dfe6f5d0
Grammar: Fix comments in template params not tokenized (#3018)
fix #3017

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-03-22 02:53:07 +00:00
Timothee Guerin 077db13c8d
Generate TypeScript decorator signatures from `extern dec` (#2122)
Note this is added to `tspd` which is not published yet so this can be
iterated over without any issues.

Adds a decorator signature generator. Generates 2 files:
- `<namespace>.ts` : Contains the decorator signatures that can be
imported and when declaring the decorators functions
- `<namespace>.ts-test.ts`: Contains some test using typescript type
system to make sure the package does reexport the right `$<name>` for
each decorator

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-03-19 23:08:59 +00:00
Timothee Guerin 743c4b0a39
Fix another set of accessibility issues (#3031) 2024-03-19 18:57:02 +00:00
Timothee Guerin 4199f83575
Upgrade dependencies march 2024 (#3027)
General update of all dependencies, notable
- typescript 5.4
- vitest 1.4
2024-03-18 10:52:06 -07:00
Timothee Guerin 6d42ca6e65
Deprecate projected name (#2910)
fix [#2832](https://github.com/microsoft/typespec/issues/2832)
2024-03-13 12:48:07 -07:00
Timothee Guerin 00996bbe30
Don't prevent going to next stage when a warning is elevated to an error (#2983)
fix #2972
2024-03-12 22:14:42 +00:00
Timothee Guerin 128a508c25
Allow encode on a union (#2992)
fix [#2969](https://github.com/microsoft/typespec/issues/2969)
2024-03-12 14:49:17 -07:00
Timothee Guerin d8576effd5
Website & Docs Cleanup (#3002)
Co-authored-by: Mario Guerra <85648637+mario-guerra@users.noreply.github.com>
Co-authored-by: Libba Lawrence <llawrence@microsoft.com>
Co-authored-by: Allen Zhang <allenzhang@live.com>
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-03-11 18:56:35 -07:00
Timothee Guerin 6d5fb9c047
Bump chronus github with fix to not crash on existing release (#2995) 2024-03-06 19:48:53 +00:00
Timothee Guerin 7312314bcb
Remove old message burried in changelog (#2989) 2024-03-05 16:05:57 -08:00
Timothee Guerin 9881002f1c
Bump versions for release march 2024 (#2988) 2024-03-05 15:31:47 -08:00
iscai-msft 4cafd969de
Add json schema test library (#2987) 2024-03-05 22:14:58 +00:00
Timothee Guerin d5380fb8e1
Add release notes for march 2024 release (#2986) 2024-03-05 13:36:38 -08:00
Timothee Guerin 6a9c62ad24
Feature: Code fixes (#2888)
closes #615

## Code fixes added

### Suppress
![Kapture 2024-02-05 at 15 16
22](https://github.com/microsoft/typespec/assets/1031227/644014a3-9352-4bd4-b1b8-0d314c627405)

### `number` -> `float64` typo fix

![Kapture 2024-02-06 at 09 50
28](https://github.com/microsoft/typespec/assets/1031227/65b2e9aa-c510-440f-a1c6-7851611b65a2)

### Enum to extensible enum in typespec-azure

https://github.com/Azure/typespec-azure/pull/258

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-03-05 11:51:21 -08:00
Timothee Guerin abba29c173
Validate playground samples and fix docs to deprecated version (#2977)
fix #1560

Json schema emitter also didn't respect the `noEmit` flag
2024-03-04 23:35:17 +00:00
Timothee Guerin de6bd7bc30
Go to import (#2978)
fix #1294
![Kapture 2024-03-01 at 14 41
07](https://github.com/microsoft/typespec/assets/1031227/8be68f83-4eca-421c-b6dd-27bc1eed141f)
2024-03-04 15:15:19 -08:00
Timothee Guerin 82fab0a5e6
Fix: Authentication on containing namespace (#2980)
fix #2979

Authentication wasn't resolving values set on the namespaces.
2024-03-04 10:55:35 -08:00
Timothee Guerin 01ba99b061
Fix dup doc (#2976)
Before
<img width="465" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/b620cac2-b70a-4a99-a784-bf03d55bd28b">

Now
<img width="413" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/d2a0b293-7924-44e7-9e1c-036ff40f1b6d">
2024-03-01 20:50:11 +00:00
Timothee Guerin 8c7c76bf8e
`isErrorModel` check for base models (#2968)
fix #2957
2024-03-01 01:59:52 +00:00
Timothee Guerin fa8b959491
Feature: Spread `Record<T>` (#2920)
fix  #2785
2024-02-29 16:47:23 -08:00
Timothee Guerin 9654dd836b
[OpenAPI3 Emitter] Add option to map `safeint` to `double-int` (#2933)
fix  #2367 
Format was added to the schema registry so we are safe to use that now
https://spec.openapis.org/registry/format/double-int.html

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-02-29 16:05:41 -08:00
Timothee Guerin 02ed01e79b
Improved ref docs for model (#2951)
fix https://github.com/Azure/typespec-azure-pr/issues/3861
fix #2232
Generate docs for model properties and reference models within the same
package
<img width="1213" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ae7eccd0-97d8-401e-b07f-3375c7b41446">
2024-02-29 07:21:13 -08:00
Timothee Guerin 717af6421f
Deprecate `@service` version and allow `@OpenAPI.info` to take all properties allowed by openapi (#2902)
fix [#2821](https://github.com/microsoft/typespec/issues/2821)

## Deprecate `@service({version`

Using this property will emit a deprecation warning

## Cover everything with `@OpenAPI.info`

Makes sure all the properties allowed on the `info` object of openapi
specification can also be provided in `@info`. The properties will
either override other ways of specifying those previously or be the only
way.
- `@info({description` would override `@doc` on service namespace
- `@info({summary` would override `@summary` on service namespace
- `@info({title` would override `@service({title}` on service namespace
2024-02-28 22:56:09 +00:00
Timothee Guerin 9d8cfb016e
Fix don't emit shared route error when verb don't match (#2948)
fix [#2925](https://github.com/microsoft/typespec/issues/2925)

Stop emitting the error if there is a shared route and a non shared
route on a different verb.

Also improve the error: 
- change message to be a little more clear
- emit the error on every offending operation not just the first one we
find an duplicate

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-02-28 22:17:46 +00:00
Timothee Guerin c9c1f3e442
Validate `@useAuth` is unique on node (#2958)
fix #2787 

having multiple has no effect, the latest value will override the
previous ones so there is no reason to use `@useAuth` twice on the same
node

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-02-28 21:52:19 +00:00
Timothee Guerin f884772255
Fix: File with only comment and one on the first line reorder comments (#2955)
fix #2508
2024-02-28 21:24:07 +00:00
Timothee Guerin 8b062e33bb
Update http authentication docs with new operation level auth and scopes (#2960)
PR added support for it but we need to update the docs to explain the
new feature.

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-02-28 19:40:28 +00:00
Timothee Guerin 628517e0c2
Remove prettier2.0 support in prettier plugin (#2956)
fix #2760 
`@typespec/prettier-plugin-typespec` dropped support for prettier 2.0.
Update to 3.0 to use the new version of the plugin.
2024-02-28 11:17:30 -08:00
Timothee Guerin 66c2df18e2
Do not run decorators that have missing args (#2959)
fix [#3940](https://github.com/Azure/typespec-azure-pr/issues/3940)
2024-02-27 11:04:00 -08:00
Vasil Markoukin d2d397cb67
Operation level authentication and scopes (#2901)
Hi! 🖖🏻 
This PR resolves #2624 by implementing the [design
doc](https://gist.github.com/timotheeguerin/56690786e61a436710dd647de9febc0f),
but in its initial form:
- `@useAuth` can now be applied not only to service namespace, but to
interfaces and operations as well. Its arguments override all
authentication, which was set for enclosing scopes.
- OAuth2 scopes can now be set at operation level (though, the code
doing this in OpenAPI emitter is a bit clunky).
- New `NoAuth` authentication option allows to declare optional
authentication (`NoAuth | AnyOtherAuth`) or override authentication to
none in nested scopes.

This implementation does not introduce new `@authScopes` decorator as
design doc comments suggest, and here's why:

1. It does not compose well with `@useAuth` at operation level. For
example
```
...
@useAuth(BasicAuth)
@authScopes(MyOauth2, ["read"])
op gogo(): void
```
Should that be equivalent to `BasicAuth | MyOauth2`, or to `[BasicAuth,
MyOauth2]`?

2. Introducing new decorator would increase complexity, but (imho) it
would not reduce the amount of boilerplate:
```
alias MyOAuth2 = OAuth2Auth<{ ... }>;

@useAuth(MyOAuth2)
@authAcopes(MyOauth2, ["read"])
@service
namepsace Foo;
```
vs
```
model MyOAuth2Flow<T extends string[]>  {  ...  };
alias MyOauth2<T extends string[]> = Oauth2Auth<[MyOauth2Flow[T]]>

@useAuth(MyOAuth2<["read"]>)
@service
namepsace Foo
```

I would be happy to hear any feedback and apply suggested changes.

And thanks for a convenient development setup and thorough test
coverage!

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-02-27 07:39:30 -08:00
Brian Terlson aa6e53f4ab
Add `getOpenAPI3` to OpenAPI3 emitter (#2950)
This function is useful when you want to work with the OpenAPI 3
directly, or don't want to write it to disk for some reason.

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-02-26 22:44:26 +00:00
Timothee Guerin 15702e82f4
Move compiler utils to `/utils` exports (#2919)
Provide a new exports `/utils` where we can export utils that are
commonly used in libraries and emitters but not tied to typespec
directly(deepClone, deepEquals, etc.)
2024-02-23 17:48:19 +00:00