-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specifying interface in operation props causes emitter to crash #3504
Comments
This shouldn't crash but what would you expect this to do? |
|
I want the error to be output in the following form. Note that the content of the message is tentative.
This was reproduced by calling |
yep that's exactly what I would expect to happen, I was just wondering if you were expecting this to produce some OpenAPI3 output. |
fix #3504 When unsuitable types are specified in the model property, the invalid code location is now reported instead of throwing an error. When compiling the following tsp file, it is reported as follows ```tsp interface TestInterface1 { get1(prop: TestInterface1): TestInterface1; } ``` ``` Diagnostics were reported during compilation: /projects/typespec/packages/samples/scratch/main.tsp:2:8 - error @typespec/openapi3/invalid-model-property: 'Interface' cannot be specified as a model property. > 2 | get1(prop: TestInterface1): TestInterface1; | ^^^^ Found 1 error. ``` --------- Co-authored-by: Timothee Guerin <tiguerin@microsoft.com> Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
Clear and concise description of the problem
When using “@typespec/openapi3”, specifying interface in operation props causes emitter to crash.
From a light reading of the implementation, it seems to me that it is not intended to specify an Interface in this ModelProperty section. In this case, why not make it an error message to the effect that “Interface cannot be specified in ModelProperty”?
Here is a simple example: both TestInterface1 and TestInterface2 generate the same error.
https://typespec.io/playground?c=aW50ZXJmYWNlIFRlc3RJyA4xIHsKICBnZXQxKHByb3A6zx4p0BE7Cn0KCtdMMiB7fQoKb3DETzLUTzLQTzI7Cg%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D
Here is the current hard to understand error.
Checklist
The text was updated successfully, but these errors were encountered: