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

300 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin 21edcb8f76
Add release notes for 0.56.0 (#3294)
Fixed up cspell not validating `.chronus` and causing some typo in
release notes

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-05-07 21:02:14 +00:00
Timothee Guerin cb6fea49d7
Split libraries from emitters (#3258)
Makes it easier to discover our emitters

also cleanup a reference to non existent json-rpc emitter
2024-05-02 16:54:35 +00:00
Abiria 7517c9175e
docs: fix incorrect example code in namespaces.md (#3195)
## Backgrounds

I first reported this on discussion: #3194

## Issue description

There is a code sample
[here](https://typespec.io/docs/language-basics/namespaces#using-namespaces)
describing the scope of an item introduced by `using`.

```ts
namespace One {
  model A {}
}

namespace Two {
  using One;
  alias B = A; // This is valid
}

alias C = One.A; // This is not valid
alias C = Two.B; // This is valid
```

## Expected result

The code should failed to compile because of `One.A`.

## Actual result

It compiles without any warning.

## How to fix

It appears that the original intent was to show that accessing an item
introduced with `using` outside the scope of `using` is not possible. In
this code, the 'invalid accessing' is `Two.A`.

## Changes

- change `One.A` to `Two.A`
2024-04-23 02:21:09 +00:00
Timothee Guerin 1987a56220
Fix password flow (#3196)
fix [#3137](https://github.com/microsoft/typespec/issues/3137)
2024-04-23 00:53:04 +00:00
Timothee Guerin 1265330298
Update to Body consistency in http request (#2945)
fix [#2868](https://github.com/microsoft/typespec/issues/2868)

- Change meaning of `@body` to mean this is the body and nothing will be
excluded(show warning on containing metadata)
- Add new `@bodyRoot` which has the same purpose as the old `@body`(
Allows changing where the body is resolved from but allows mixing with
metadata.
- Add new `@bodyIgnore` which allows a property to be ignored from the
body
- Provide a new body resolution common function for request and response

also fix #2075
## Examples from original issue

1. [Inconsitency between request and
response](https://cadlplayground.z22.web.core.windows.net/prs/2945/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7Cgp1c2luZyBUeXBlU3BlYy5IdHRwOwoKLyoqCiAqIEJhc2VsaW5lIDE6IEhhdsQqYEBoZWFkZXJgIHByb3BlcnR5IG9ubHkgaW4gcmVxdWVzdMYLc3BvbnNlxAl1bMUTbm8gYm9kecRXUscpxBA6IHZvaWTGFnPFM80WLwpAcm91dGUoIi9i5wCNIikKQGdldCBvcCDIEygg5wCWIGN1c3RvbUjFDTogc3RyaW5nKToge90hIH0g6gD0Q2Fz5QDwQWRkxBtgQHZpc2liaWxpdHlgIHRv9AEBYmVoYXZlIGRpZmZlcmVudGx5IGZvcukBEGFuZOkBES7yAQB7ff8A%2FuUA%2FmNhc2UxIikKb3AgxQso6wCYKCJub%2BQBGOkA5XjuAPvfKsUqIH3vAQMy%2BgEDbm9uIGFubm90YXRlZOoBB%2BoB7GVtcOQBF%2FUB7%2FQA78UU7wDtMuoA7TL1AO3%2FAOXMIuUA3Q%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
2. [Inconsitency between different
ways](https://cadlplayground.z22.web.core.windows.net/prs/2945/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZdmVyc2lvbmluZyI7Cgp1c2luZyBUeXBlU3BlYy5IdHRwO9AVVskyOwoKQHNlcnZpY2UKQMdJZWQoxyFzKQpuYW1lc3BhY2UgTXlTxik7CmVudW0gyCQgewogIHYxLMQGMiwKfQoKQHJvdXRlKCJ0MSIpIG9wIHQxKCk6IHZvaWQ7IC8vIDIwNMUNyigyxygyxCh7fccmMM8mM8cmM8UmQGhlYWRlciBmb286IHN0cmluZ9g5NMc5NMY5dmlzaWJpbGl0eSgiZ2F0ZXdheSIp30jFSDXHSDXcSP8AmMxQNsdQNsVQ1THGFiJhYmMifco5N8c5N8U5QGFkZOsBtC52MvMAzsR6IGluIHYxykc4x0c430fFRyzpANpvdGhlcthe&e=%40typespec%2Fopenapi3&options=%7B%7D)

## Breaking changes 
Azure spec PR showing scale of breaking changes
https://github.com/Azure/azure-rest-api-specs/pull/27897
### `@body` means this is the body
This change makes it that using `@body` will mean exactly this is the
body and everything underneath will be included, including metadata
properties. It will log a warning explaining that.

```tsp
op a1(): {@body _: {@header foo: string, other: string} };
                ^ warning header in a body, it will not be included as a header.
```

Solution use `@bodyRoot` as the goal is only to change where to resolve
the body from.

```tsp
op a1(): {@bodyRoot _: {@header foo: string, other: string} };
```




### Empty model after removing metadata and visibility property result
in void always
This means the following case have changed from returning `{}` to no
body

```tsp
op b1(): {};
op b2(): {@visibility("none") prop: string};
op b3(): {@added(Versions.v2) prop: string};
```

Workaround: Use explicit `@body`

```tsp
op b1(): {@body _: {}};
op b2(): {@body _: {@visibility("none") prop: string}};
op b3(): {@body _: {@added(Versions.v2) prop: string}};
```

### Status code always 200 except if response is explicitly `void`

```tsp
op c1(): {@header foo: string}; // status code 200 (used to be 204)
```

Solution: Add explicit `@statusCode`
```tsp
op c1(): {@header foo: string, @statusCode _: 204};
op c1(): {@header foo: string, ...NoContent}; // or spread common model
```


### Properties are not automatically omitted if everything was removed
from metadata or visibility

```tsp
op d1(): {headers: {@header foo: string}}; // body will be {headers: {}}
```

Solution: use `@bodyIgnore`

```tsp
op d1(): {@bodyIgnore headers: {@header foo: string}}; // body will be {headers: {}}
```

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-04-17 11:20:25 -07:00
Timothee Guerin 6b3bd9a8f1
Feature: Add Xml library (#3035)
Add xml library following the approved design.
fix #2970

Only minor change was inverting the parmaeters for `@ns(namespace,
prefix` instead of `@namespace(prefix, namespace)` which makes it
clearer with the other overload `@ns(namespace: EnumMember)`

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-04-09 15:33:46 -07: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 d5577b1f11
Docs: Add documentation on emitter scoping (#3016)
fix [#2860](https://github.com/microsoft/typespec/issues/2860)

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-04-02 17:51:10 +00:00
emi0x7d1 fbe9da657e
project-root typo corrected in docs (#3083) 2024-04-01 08:10:37 -07:00
Timothee Guerin e31309e5a7
Fix codefixes docs (#3045) 2024-03-28 19:41:27 +00:00
LadyCailin 4e1d30ddce
Update inconsistent docs (#3072)
`@server` works to provide values for the `servers` object, as is
documented elsewhere in the same files. This PR updates the table to
reflect that. Closes #3071.
2024-03-28 13:50:21 +00:00
Jose Manuel Heredia Hidalgo baac24ac00
Fix emitter docs code examples (#3047)
Fixing a couple of wrong, missing, and un-needed imports in the snippets
2024-03-22 22:59:31 +00:00
Timothee Guerin a8f849747c
Clarify multi json part docs (#3014)
fix [#2962](https://github.com/microsoft/typespec/issues/2962)
2024-03-22 03:43:39 +00:00
Timothee Guerin 743c4b0a39
Fix another set of accessibility issues (#3031) 2024-03-19 18:57:02 +00:00
Peter Marcu 9e655a95f5
Fixing alt text on website (#3025)
This PR should make sure there is alt text matching the image name on
each of the image elements.
2024-03-18 07:54:57 -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 72fb582b3c
Add gif to vscode readme and rerelease (#3003) 2024-03-07 15:46:27 -08:00
Mario Guerra c31aafa07f
grammar fixes (#3000)
First round of website grammar fixes.
2024-03-07 17:25:25 +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
Allen Zhang cc1774fd6f
Updating doc links to VS Extension (#2971)
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-03-01 10:38:10 -08: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 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
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
Timothee Guerin 02cd6f4d8f
Update encoding.md (#2903) 2024-02-09 21:55:52 +00:00
Timothee Guerin 24d3ba0add
Update docs to clarify range of `numeric`, `integer`, etc. and meaning of unixTimestamp (#2893)
fix #2892 Clarify `numeric`, `integer`, `decimal`, `float`
fix #2887 Clarify unixTimestamp encoding

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-02-09 01:37:32 +00:00
Timothee Guerin 7452fe9a57
Update dependencies - feb 2024 (#2900)
General dependency updates, notable:
- typescript 5.3
- chronus 0.6.0 (BREAKING  THE CHANGELOG FORMAT)
2024-02-08 15:14:01 -08:00
Timothee Guerin 9320c4484d
Add release notes for february relase (#2889) 2024-02-06 13:10:31 -08:00
Timothee Guerin 8ed1d82e7c
Add support for openIdConnect auth scheme (#2811)
fix [#2774](https://github.com/microsoft/typespec/issues/2774)
2024-02-05 14:38:55 -08:00
Will Temple 15f6dbe150
[compiler] Add optional validation message to `@pattern` decorator. (#2863)
Closes #2718

This change adds support for an optional message that emitters may use
to communicate the context of a pattern validation error.

I also added some baseline tests for `@pattern` since there were none in
decorators.spec.ts.

---------

Co-authored-by: Will Temple <will@wtemple.net>
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2024-02-02 02:32:51 +00:00
Timothee Guerin be9f6d8145
Rename references from microsoft.github.io/typespec to typespec.io (#2858)
All reference but the README as it is being rewritten here
https://github.com/microsoft/typespec/pull/2855
2024-01-30 12:58:42 -08:00
Timothee Guerin 63f7e546fd
Vscode publish (#2838)
Extension
https://marketplace.visualstudio.com/items?itemName=typespec.typespec-vscode
2024-01-29 22:01:33 +00:00
Timothee Guerin 9bf31a65c8
More rush cleanup - bundler uploader (#2841) 2024-01-26 23:02:45 +00:00
Jordan Danford 9f556004ec
Clean up capitalization, parentheses, and phrasing in docs (#2817)
I updated library documentation links
(https://microsoft.github.io/typespec/libraries =>
https://typespec.io/docs/libraries), should I update the other
https://microsoft.github.io links as well?
2024-01-25 10:40:16 -08:00
Timothee Guerin e542ce8991
Fix website docs slug for /docs (#2823)
Issue was we didn't have a doc at `/docs` anymore because the docs
entrypoint was `/docs/introduction/installation`
2024-01-24 12:02:06 -08:00
Mark Cowlishaw f31fae0e48
Add release notes for January release (#2813) 2024-01-23 14:04:06 -08:00
Timothee Guerin 55ea44250d
Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791)
Add vitest ui package and `test:ui` command to popup the vitest UI
https://vitest.dev/guide/ui

Import the common vitest config from the workspace so each package
doesn't need to define all of it.
Added `watchExclude: []` to the common config to preven vitest from
excluding dist and node_modules folder which is required so it can auto
rerun the test on when a dependency (monorepo dep) rebuilds

Added debug config to debug the current test. As the vitest extensions
is quite unreliable this should help
2024-01-22 09:56:55 -08:00
Timothee Guerin 5af94f0762
Website public beta (#2418)
This is a feature branch containing the progress for the website

URL: https://tspwebsitepr.z22.web.core.windows.net/prs/2418/
2024-01-19 09:42:25 -08:00
Timothee Guerin 8f4ee2dfdc
Feature: `@encodedName` decorator (#2779)
fix [#2650](https://github.com/microsoft/typespec/issues/2650)

- [x] Add `@encodedName` decorator in the compiler
- [x] Add support in openapi3 emitter 
- [x] update docs

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-01-12 21:28:31 +00:00
Timothee Guerin 55e232d553
Add a new init template to setup a library (#2766)
Add a new library template with:
- `@alernateName` decorator with some custom diagnostics and tests for
it.
- a linter rule and 2 rulesets(`recommended` and `all`)
2024-01-04 12:22:21 -08:00
Timothee Guerin 8d5528363a
Stop warning user when `tsp init` a template without `compilerVersion` specified (#2764)
fix #2741 Add doc for `compilerVersion`
fix #2742 Stop warning
2024-01-04 18:50:02 +00:00
Timothee Guerin 9c7bf80187
Migrate test framework to vitest (#2769)
Get rid of mocha and upgrade to vitest which is a more modern
alternative providing, watch, direct typescript compilation out of the
box, expect library and more.

Advantage over mocha:
- Much better cli
  -  watch mode
  - better diff
- Better extension:
  -  tree organization for files too (not everything flattened)
- update in real time the test(no more need to refresh manually to
discover where are the tests)
  - just a little buggy
- Compiles typescript directly
- provides more expectation apis(like jest)

Cons over mocha: 
- Slower(about 2x) but that means we don't need to build the test as
part of build which would speed up that part(not as much as is lost)

Todo: 
- typespec-azure migration
2024-01-02 11:40:29 -08:00
Timothee Guerin da99aa955b
Detach linter from `$lib` and add state declaration to `$lib` (#2773)
fix #2301 

## Deteach the linter from `$lib`

Having the linter rules defined in `$lib` caused this circular reference
where the rules would call to some accessor that needed the $lib
diagnostics.

With this we keep $lib as manifest and helper functions only.

## Add state key declaration
```ts
export const internalLib = createTypeSpecLibrary({
 state: {
    authentication: { description: "State for the @auth decorator" },
    header: { description: "State for the @header decorator" },
    ...
});

// use with StateKeys.authentication
```
2023-12-22 17:27:00 -08:00
Timothee Guerin 0a77b5f61e
Template engine naming utils (#2765)
## Add 3 new helper functions to be able to change the casing in
templates

```
naming.pascalCase
naming.camelCase
naming.kebabCase
```


## Update the `emitter-ts` to interpolate the emitter name

## Add snapshot test for templates

This way we can see what instantiating the template does at review time
and catch errors that wouldn't make the template crash the e2e test but
would still not be optimal
2023-12-20 21:02:09 +00:00
Timothee Guerin 9aa57063d9
Template for setting up an emitter (#2736)
## Add a new template for scaffolding an emitter

`emitter-ts` template setup the following:
- basic emitter files
- typescript
- test with node test runner with basic test and test host setup
- prettier
- linting with eslint 

## Change to the init area

- Added a new `--template` cli option to allow selecting the template
without a prompt.
- Refactor to make it easier to test. **Note that none of the API is
exposed yet so its just for internal use.**

## Added e2e test for templates

Scafold the template and then run commands like `npm install`, `npm run
build`, `npm run test`, etc. to make sure everything is done correctly.

This is quite costly so might be worth separating in a different step
2023-12-19 16:13:49 -08:00
Will Temple cb92f49e0a
[compiler] Named instantiation of template arguments (#2546)
Implementation of named template arguments as described in #2340.

I added a new syntax node (TemplateArgument), and a cover grammar for
this node:

`<Expression> ('=' <Expression>)?`

Rather than ExpressionNode, the type of a template argument is now
`TemplateArgumentNode`.

If the `=` is parsed, we assert in the parser that the first Expression
must be a "bare identifier" (i.e. a TypeReference with `target:
Identifier`) and unwrap the identifier to produce a clean AST with
`name?: Identifier

Template arguments are evaluated in the order that they were declared,
not in the order they are specified in the instantiation. The new
template argument checker _replaces_ the previous one, and it performs
normalization of argument order and typechecking of template arguments
all in one pass.

TODO:
- [x] Review templates across core libraries to ensure that template
arguments have good names.
- [x] Documentation of new behavior in website.
- [x] Semantic/tmlanguage colorization of tokens. 
- [x] Validate that the AST printer produces the correct text for the
new template argument nodes and that the output is well-formatted.
- [x] Completion of template argument names in argument position.
- [x] Hover context on template argument names in instantiation.

Closes #2340

---------

Co-authored-by: Will Temple <will@wtemple.net>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
2023-12-18 14:38:16 -05:00
Will Temple aae7166f0a
Rename template parameters for clarity and consistency (#2726)
This is in preparation for merging named template argument
instantiation.

---------

Co-authored-by: Will Temple <will@wtemple.net>
2023-12-18 13:44:37 -05:00