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

16 Коммитов

Автор SHA1 Сообщение Дата
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
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 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 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 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 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
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
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
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
Timothee Guerin c749b1148f
Split libraries from standard library (#2674)
Having the std and other libraries merged together always made it harder

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-11-21 20:13:40 +00:00