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

300 Коммитов

Автор SHA1 Сообщение Дата
Timothee Guerin 4fac4d50c3
Feature: Sepecify http endpoints using @server decorator (#581) 2022-06-10 15:27:59 -07:00
David Wilson 660f3c6fe8
Add support for operation templates and operation signature reuse (#552)
* Add support for operation templates and operation signature reuse

* Replace `OperationInstanceNode` with `OperationSignature` types

* Add Rush change file

* Skip templated operations when scanning for operation routes

* Add operation signatures sample

* Fix formatter output for templated operation references

* Create a scope for operation statements to bind template parameters

* Add another operation signature to the signatures sample

* Add an example of operation signatures used in a templated interface

* Update language grammar specification for new syntax

* Format signatures.cadl

* Convert `OperationSignature` types to real syntax nodes

* Use `expectTokenIsOneOf`

* Update `InterfaceMember` in language specification

* Use `op is Sig` syntax instead of previous `op: Sig` syntax

* Non-working updates to tmLanguage grammar

* Nick's suggested changes

* Update tmLanguage and tests

* Add a tmLanguage test for templated operation signatures

* Add Rush change file for vscode extension
2022-06-02 11:12:39 -07:00
Nick Guerrera 9ff9e8e3ac
Allow empty tuples (#525) 2022-05-10 15:28:41 +00:00
Timothee Guerin 2a9e316b14
Add docs for OpenAPI library (#491) 2022-05-04 10:31:16 -07:00
David Wilson c0b11ce960 Add documentation for REST library decorators and auto-route logic 2022-05-04 18:12:28 +03:00
David Wilson bf68c33e4c Add documentation for important core decorators 2022-05-04 18:12:28 +03:00
Mike Kistler 15b350ad87 Add/improve doc for @summary and @doc 2022-05-02 14:46:08 -05:00
Nick Guerrera db34924478
Update to Unicode 14.0 and disallow U+FFFD (#496) 2022-05-02 18:56:41 +00:00
Timothee Guerin 20b7e4a1e7
Bump ecmmarkup version to get rid of deprecated packages (#487) 2022-04-28 08:08:26 -07:00
Timothee Guerin 30b9b5cc1a
Refactor: rename `mixes` to `extends` for interfaces (#484) 2022-04-27 15:00:57 -07:00
Timothee Guerin 5d225da253
Add duration built-in type to tutorial: (#408) 2022-04-05 19:19:06 +00:00
Alexander Batishchev 91073551c6
Update cadl-for-openapi-dev.md (#394)
* Fixed broken url markup
* Rephrased "one and another"
2022-04-01 10:54:27 -05:00
Timothee Guerin 161e6a00e5
Add missing docs: prop defaults, template defaults, libraries getting started (#376) 2022-03-29 20:10:10 +00:00
Timothee Guerin 4342c3cc50
Service description in openapi3 spec (#271) 2022-02-24 01:24:18 +00:00
Nick Guerrera b1be3793e4
Allow `op` in interfaces (#270) 2022-02-17 20:55:51 +00:00
Timothee Guerin 77b8507ba2
Fix invalid use of verb decorators in docs (#260) 2022-02-15 17:55:26 +00:00
Brian Terlson a055e3f165
Implement template argument defaults (#241) 2022-02-10 12:19:28 -08:00
Nick Guerrera f8b59f2199
Bump some dependency versions (#237) 2022-02-07 16:28:32 -06:00
Timothee Guerin 4470384791
Version mismatch spec gen fix (#219) 2022-02-03 08:39:53 -08:00
Timothee Guerin ba68290633
Seperate openapi decorators into own library (#205) 2022-02-02 14:55:10 -08:00
Timothee Guerin 0a872034fd
--emit and emitter api (#41) 2022-02-02 12:22:38 -08:00
Brian Terlson b8c461526f
Implement projections and versioning (#16)
Adds support for projections, an experimental language feature that lets users write code to modify types dynamically, and a package for implementing versioning on top of this functionality.
2022-02-01 14:18:15 -08:00
Allen Zhang a216108b67
[Core] Rename format to pattern (1/2) (#173)
* Rename format to pattern

* Update package change log
2022-01-14 12:07:32 -08:00
Mike Kistler a2cb1802b2 Add statusCode decorator for http status code 2022-01-10 10:16:22 -08:00
Mike Kistler a1c23863ac Add doc for discriminator decorator (and fix a few typos) 2022-01-09 06:15:58 -08:00
Mike Kistler ec33166d17 Minor fix to cadl-for-openapi-dev doc 2021-12-16 10:16:03 -06:00
Timothee Guerin b29baa9535
Improvements to the formatter(spread, interface mixes, ...) (#122) 2021-12-14 13:15:35 -08:00
Nick Guerrera 0aa2105696
Use double quotes as required in tutorial (#113) 2021-12-08 10:30:08 -06:00
markcowl 727ade7833 Updating examples in swagger cheatsheet 2021-12-02 16:43:56 -08:00
Mark Cowlishaw 29bc09949e
Fix for resource to route rename 2021-12-02 11:55:03 -08:00
Nick Guerrera f64d9d3dfd
Remove incorrect use of op inside interfaces in tutorial (#98) 2021-12-01 14:35:44 -06:00
Mike Kistler 9c4a2cf908
Merge pull request #83 from mikekistler/cadl-for-openapi-dev
Add Cadl doc for the OpenAPI developer
2021-12-01 12:17:55 -06:00
Mike Kistler ba062e52ca Fixes for PR Review comments 2021-11-30 07:47:10 -06:00
Nick Guerrera ec315002da
Add new features to tutorial (#85) 2021-11-30 13:26:22 +00:00
Mike Kistler 200af60bf0 Add Cadl doc for the OpenAPI developer 2021-11-29 07:03:15 -06:00
Nick Guerrera 93a163484c
Update tutorial (#78) 2021-11-28 10:38:03 -06:00
Timothee Guerin 47f73ee082
Fix wrong library import in rest init template (#76) 2021-11-23 19:24:41 +00:00
Nick Guerrera e7d656075b
Small formatting and syntax highlighting improvements (#73)
1. Format *.cadl on save in our repo. This required some extra knobs in
.vscode/settings.json and .prettierrc.json. These are not required when
referencing the prettier plugin via npm, but we need a workaround to consume
the plugin this way from source.

2. Fix a formatter bug with operations that return anonymous models where
the braces around the return model were dropped.

3. Add cadl syntax highlighting to markdown ```cadl blocks
2021-11-22 13:04:36 -06:00
Nick Guerrera 53cbecc69c
Use prettier for markdown too (#72) 2021-11-19 15:52:17 +00:00
Timothee Guerin 02d9f1299c
Feature: docker image (#57) 2021-11-12 11:17:46 -08:00
Timothee Guerin 47a4149d50
Bump ecmarkup dependency and subdependency to fix deprecation warning (#51) 2021-11-10 08:57:57 -08:00
Timothee Guerin aa4eed3ad3
Feature: init lets you copy files with basic templating (#7) 2021-10-27 09:44:12 -07:00
Nick Guerrera 2c5454dc1a Port build process to new OSS repo 2021-10-19 15:21:39 -05:00
Mike Kistler 0b024d674c Add emitter for OpenAPI 3.0 (#745) 2021-08-27 10:25:58 -05:00
Nick Guerrera d117e1ac74 Rename packages in preparation for OSS release (#714) 2021-08-12 08:38:20 -05:00
Nick Guerrera 8e0f6be0f4 Rename ADL to Cadl (#678) 2021-08-02 13:14:53 -05:00
Nick Guerrera 9d3e732f78 Update tutorial with language changes (#535) 2021-05-04 15:07:35 -07:00
Nick Guerrera a6d9bc552c Implement basic parser error recovery (#453)
With this change, the parser no longer throws when it encounters an
error, but continues on to report subsequent errors to the user as
well.

For now, however, evalADLScript still throws if there are any parse
errors. More work is needed in the parser to represent which nodes
have the errors and so forth before we can meaningfully analyze a
syntax tree for source that had errors.

Our default response to a token that doesn't match our expectation is
to insert a matching token before the offending token. This is
effectively what is happening wherever we have parseExpected() without
checking the return value. Also when we expect an identifier and do
not find one, we insert an identifier with a unique yet unspeakable
name. In fact, anywhere we hit an invalid expression, we insert one of
these identifiers.

Statements are easier to correct than expressions, and our approach
there is different. Every statement in the language begins with a
reserved word, an at-sign, or a semicolon. If the leading token for
statement is none of these, we report an invalid statement starting at
that token and ending immediately before the next token that is one of
these.

There are also case-by-case refinements to this insertion
strategy. For example, we replace errant semicolons with commas in
comma-only delimited lists rather than inserting semicolons in front
of the comma.

In other cases, we take the approach of parsing a grammar that is a
superset of the language specification, augmented with known common
errors. For example, we parse decorators in many more places than
actually allowed (and signal an error still, of course). We do the
same for import statements inside namespaces.

Over time, I expect that we'll need to do more of these more
deliberate and one-off corrections, but this change still performs
relatively well and it provides the foundation for such improvements.

A major challenge with the approach of correction by inserting tokens
is that it can hang the parser such that it keeps inserting tokens
without making forward progress. To mitigate the risk of such bugs,
all list constructs that are susceptible to this are driven by the
same parseList() routine. This routine has an escape hatch in the loop
where it bails and assumes we've hit a bad representation for the end
of the list if any loop iteration fails to make progress.

A trivial example of a construct that would hit this without this
check is `model M { ]`. The parser proceeds as follows in that case:

1. Parse model keyword: OK.
2. Parse model name (M): OK.
3. Parse open brace: OK.
4. Expect property name, see close bracket: ERROR, insert synthetic
   identifier for property name.
5. Expect colon, see close bracket: ERROR, insert colon.
6. Expect property type, see close bracket: ERROR, insert synthetic
   identifier for property type.
7. Expect semicolon, see close bracket: ERROR, insert semicolon.
8. Observe that the position has not advanced after a full loop
   iteration of parsing properties: ERROR, replace with close brace,
   exit loop.

(Note that everywhere I'm saying "insert" or "replace" here, there's
no literal array of tokens that we're mutating, we are just taking the
code paths we would take if those edits were made to the source. There
is rather an implicit "behave as though" replacing/inserting, but that
is really an implementation detail and not part of the logical
algorithm.)

Without the vital step 8, we could convince ourselves that we've
parsed a real property and try to move on to the next one, and do this
over and over again, creating infinitely many synthetically named
properties of synthetically named types!

This change also adjusts many of our error messages, borrowing from
the TypeScript compiler's terse tone for mundane errors.

It also fixes various issues with imprecise or sub-optimal squiggly
locations for various errors.

There are also some ADL team developer productivity improvements in
this change...

The per-test output in Mocha Test Explorer in VS Code now shows the
input source code, the resulting syntax tree, and all parse
diagnostics formatted nicely as the CLI compiler would. The syntax
tree JSON also has boilerplate default-empty things elided and the
start and end positions augmented with line and column number.

Negative parse test cases must now provide regex(es) to match against
the reported diagnostics.

Stack traces in Mocha Test Explorer will now be reported up to 50
frames rather than 10, making it easier to diagnose a stack overflow
in the parser's recursive descent.

A new compilerAssert function is added for asserting something that
should never happen in the compiler. It takes a condition, message,
and optional source node. If the condition is not met, it throws an
AssertionError with the message and if a source node is provided, the
message will be augmented with "occurred while compiling (file) near
line (X) and column (Y)". This is used in only a couple of places
right now. I did not yet scrub the existing throws that could benefit
from this.

If a DiagnosticError or AggregateError occurs in a test, the formatted
diagnostics or inner stack traces are included in the Mocha Test
Explorer per-test output. This is done because tests don't have the
CLI catch handler that has to take special steps for these special
errors.

Note that for all Mocha Test Explorer output improvements above, if
you prefer to run tests on the command line, you can also set
environment variable ADL_VERBOSE_TEST_OUTPUT=true and get all of the
output spewed to the console.

An issue with the typing of `messages` allowed typos when used is
fixed, and the fix makes `Message.X` a `Message` and if you hover over
X in the IDE, you will see the message code, severity and text.

Finally, there's also a minor correction in the tutorial to account
for parenless decorators having been removed from the language.
2021-04-20 09:04:45 -07:00
Brian Terlson 3822a9daf8 new package names :( (#427) 2021-04-05 17:54:09 -07:00
Brian Terlson d7b5d8e0d5 Add tutorial (#424) 2021-04-05 16:44:40 -07:00