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

22 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin 78140e410d
Add paging support (#4470)
close https://github.com/microsoft/typespec/issues/705

---------

Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-11-05 01:47:23 +00:00
Timothee Guerin b4e2aaf68a
Remove docusaurus website version (#4883) 2024-10-29 17:48:51 +00:00
Timothee Guerin 0c3cd362f5
Migrate website to astro [Step 1] (#4587)
Progress for #2564 
Changes: 
- Decided to cut versioning for now. Starlight doesn't support well now
and would be a decent amount of work. Our doc have been quite stable and
this slows down the build significantly.\


The plan is as follow
1. Merge this as a parallel build to the docusaurus website
2. Add blog back
3. Cleanup things (like migrate more things out of fluentui react
components)
4. Switch the website to use this one
5. If we are happy delete docusaurus
2024-10-11 01:38:03 +00:00
Christopher Radek f69f8faf7a
Add support for defining streams (#4513)
Related: https://github.com/microsoft/typespec/issues/154

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-10-07 23:22:48 +00:00
Timothee Guerin 68c94a715b
Add url property to diagnostic (#4442)
fix [#4142](https://github.com/microsoft/typespec/issues/4142)
Every diagnostic can now define a url pointing to a documentation with
more information on how you might have this diagnostic and how to
resolve it
2024-10-04 20:20:12 +00:00
Timothee Guerin ef37eadcf8
Fix encoded names doc not referenced (#4478) 2024-09-19 18:58:30 +00:00
Timothee Guerin a336c93709
Update prettier config to format trailing commas to `all` (Default) (#4457)
fix #2159 
Long standing backlog issue that was split from an upgrade of prettier
as it created too much diff. Finally doing it
2024-09-16 20:20:57 +00:00
Timothee Guerin 977a9b5d4a
Add documentation on examples (#4074)
fix #4034
2024-08-01 18:26:02 +00:00
Timothee Guerin fb63f5765b
Remove docs for deprecated projected names (#4073) 2024-08-01 18:18:35 +00:00
Mario Guerra da41e74c17
pet store rewrite (#3958)
Rewritten from scratch to incorporate feedback from eng and arch.
2024-07-30 18:05:11 +00:00
Mario Guerra 0d8507700c
Update getting started http guide (#3684)
Revised and expanded version of the pet store HTTP example.

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
2024-07-15 15:42:17 +00:00
Timothee Guerin c2043a4da8
Add docs on identifiers (#3789)
fix #3271

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
2024-07-09 22:35:20 +00:00
Christopher Radek 8354a758b9
Add support for converting OpenAPI3 specs to TypeSpec (#3663)
fix #3038
This PR updates the `@typespec/openapi3` package to support converting
OpenAPI3 specs to TypeSpec.

## Example usage:
1. `npm install @typespec/openapi3`
2. `npx openapi3-to-tsp compile --output-dir ./tsp-output
/path/to/openapi-yaml-or-json`

## What's supported
- Parse OpenAPI3 specs in yml/json formats (via 3rd party package)
- Generates file namespace based on OpenAPI3 service name
- Populates `@info` decorator with OpenAPI3 service info
- Converts `#/components/schemas` into TypeSpec models/scalars.
- Converts `#/components/parameters` into TypeSpec models/model
properties as appropriate.
- Generates a response model for every operation/statusCode/contentType
combination.
- Operation tags
- Generates TypeSpec operations with routes/Http Method decorators
- Generates docs/extension decorators
- Most schema decorators
- Model inheritance via `allOf`
- Discriminators

## What's not supported (yet)
- auth
- deprecated directive
- combining multiple versions of an OpenAPI3-defined service into a
single TypeSpec project
- converting `#/components/requestBodies` and `#/components/responses`
into models - TypeSpec doesn't seem to generate these and I didn't find
examples in the wild where they were defined _and_ actually used so
deprioritized.
- emitting warnings/FIXMEs for unexpected/unsupported scenarios
- Probably a lot more that I'm still discovering

## Notes

When going through the TypeSpec -> OpenAPI3 -> TypeSpec loop, the
generated TypeSpec is going to be larger than the original. The biggest
contribution towards this is because I'm currently generating a model
for every possible response on every operation.

I can definitely pare this down with some simple heuristics that take
into account what default statusCode/contentTypes are, and extract the
referenced body type directly in the operation's return signature. I can
also eliminate the `@get` decorators, `@route("/")` routes, and likely
use some of the response models provided by TypeSpec.Http.

However - if I'm using this tool to convert from OpenAPI3 to TypeSpec -
I thought it might be preferable to be more explicit in the generated
output so there's no mystery on how things actually get defined. Will be
interested in feedback on this.


## Testing
For tests, I generate TypeSpec files for a number of OpenAPI3 specs.
Most of the OpenAPI3 specs I generated from our TypeSpec samples
packages. Then I'm able to compare the generated TypeSpec to the
corresponding original TypeSpec file. I've also been diffing the
OpenAPI3 specs generated from the original and generated TypeSpec files
<- these are what typically show no changes outside of known unsupported
conversions (e.g. auth).

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-07-02 22:43:49 +00:00
Timothee Guerin 7ec17161b7
Value world, object, tuple literals, const (#3022)
resolves #2046
[Playround](https://cadlplayground.z22.web.core.windows.net/prs/3022/)

Add the new syntax for object literals using `#{`. For this first
version an object literal can only contain other object literal and
other literals(string, number, boolean))

## Values axioms
1. `alias` always produces a type. If you attempt to alias a value, you
get an error.
2. A string template produces a string template type if all
substitutions are types, and a value if all substitutions are numeric,
boolean, or string values. A mixture of types and values is an error.
3. The string literal syntax always results in a string literal type
4. A string literal type may be passed as a string value when the
signature expects a value. When the signature expects either a string
literal type or a string value, it is passed as a string value.
5. A string template type can be passed as a string value when all its
substitutions are string literal types.

## Breaking change

### Removal of the `ValueType` replacement with `MixedConstraint`

This shouldn't affect anyone as you were only exposed to this if you
digged into the template parameter and looked at the constraint

## Deprecation

## Using a tuple instead of a tuple literal
-  still work
- emit a warning
<img width="1013" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/ab05359a-5ed9-4a27-a8d1-f40d1e21766f">

- provide a codefix
<img width="312" alt="image"
src="https://github.com/microsoft/typespec/assets/1031227/5ef93bdf-665f-4445-a6b2-62475efe8c16">

## Using a model expression instead of an object literal
This technically didn't work before(different from above where tuple was
used as a value) but allow this will allow us to convert most of our
decorators to use `valueof` without being breaking
![Kapture 2024-03-18 at 19 31
32](https://github.com/microsoft/typespec/assets/1031227/f6d69ab4-139e-4b01-95a3-f376b8515d1c)

## Old decorator marshalling

If a library had a decorator with `valueof` one of those types
`numeric`, `int64`, `uint64`, `integer`, `float`, `decimal`,
`decimal128`, `null` it used to marshall those as JS `number` and
`NullType` for `null`. With the introduction of values we have a new
marshalling logic which will marshall those numeric types as `Numeric`
and the others will remain numbers. `null` will also get marshalled as
`null`.

For now this is an opt-in behavior with a warning on decorators not
opt-in having a parameter with a constraint from the list above.

Example: 
```
extern dec multipleOf(target: numeric | Reflection.ModelProperty, value: valueof numeric);
```
Will now emit a deprecated warning because `value` is of type `valueof
string` which would marshall to `Numeric` under the new logic but as
`number` previously.

To opt-in you can add the following to your library 
```ts
export const $flags = defineModuleFlags({
  decoratorArgMarshalling: "value",
});
```

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2024-05-08 20:06:28 +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
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 e31309e5a7
Fix codefixes docs (#3045) 2024-03-28 19:41:27 +00: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 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
Timothee Guerin dea0c83804
Docs: multipart default handling (#2667)
part of https://github.com/microsoft/typespec/issues/2419


https://tspwebsitepr.z22.web.core.windows.net/prs/2667/next/standard-library/http/multipart.html

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-11-21 19:37:05 +00:00
Timothee Guerin 38aa320002
Add ref docs for linter rules (#2668)
Add some generated doc for the linter capability of a library.

Each linter rule can also provide a url pointing to the the full
documentation where we can get a more detailed set of examples of what
is good and what is bad.

Example for http linter 

https://tspwebsitepr.z22.web.core.windows.net/prs/2668/next/standard-library/http/reference/linter.html



![image](https://github.com/microsoft/typespec/assets/1031227/81c2dddc-fa0f-40dd-bad7-9d193f764c55)


![image](https://github.com/microsoft/typespec/assets/1031227/36652cd5-418b-43b9-bd9a-aff046cbe538)

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
2023-11-15 13:03:36 -08:00
Timothee Guerin adba3b92e6
Upgrade to docusaurus 3.0 (#2628)
Docusaurus 3.0 was just released, this new version brings up 
- react 18 which allows us to not use an outdated version here
- config can use typescript
- some perf improvement(however we already were proactive so its not
very noticable)

https://docusaurus.io/blog/releases/3.0

Typespec azure PR https://github.com/Azure/typespec-azure/pull/3823
2023-11-06 10:24:24 -08:00