-
Notifications
You must be signed in to change notification settings - Fork 51
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
azure-http-specs, validate orphan model serializable #2318
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@azure-tools/azure-http-specs" | ||
--- | ||
|
||
Add orphanModelSerializable operation to verify the JSON serialization of an orphan model |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ namespace _Specs_.Azure.ClientGenerator.Core.Usage; | |
|
||
@scenario | ||
@scenarioDoc(""" | ||
This scenario contains two public operations. Both should be generated and exported. | ||
The models are override to roundtrip, so they should be generated and exported as well. | ||
This scenario contains 4 public operations. All should be generated and exported. | ||
'OrphanModel' is not used but specified as 'public' and 'input', so it should be generated in SDK. The 'orphanModelSerializable' operation verifies that the model can be serialized to JSON. | ||
The other models are override to roundtrip, so they should be generated and exported as well. | ||
""") | ||
@global.Azure.ClientGenerator.Core.clientNamespace("azure.clientgenerator.core.usage", "java") | ||
namespace ModelInOperation { | ||
|
@@ -90,11 +91,31 @@ namespace ModelInOperation { | |
op modelInReadOnlyProperty(@body body: RoundTripModel): { | ||
@body body: RoundTripModel; | ||
}; | ||
|
||
@doc(""" | ||
Serialize the 'OrphanModel' as request body. | ||
|
||
Expected body parameter: | ||
```json | ||
{ | ||
"name": "name", | ||
"desc": "desc" | ||
} | ||
``` | ||
""") | ||
@global.Azure.ClientGenerator.Core.convenientAPI(false) | ||
@route("/orphanModelSerializable") | ||
@put | ||
op orphanModelSerializable(@body body: unknown): NoContentResponse; | ||
} | ||
|
||
@doc("Not used anywhere, but access is override to public so still need to be generated and exported with serialization.") | ||
@global.Azure.ClientGenerator.Core.usage(global.Azure.ClientGenerator.Core.Usage.input) | ||
@global.Azure.ClientGenerator.Core.access(global.Azure.ClientGenerator.Core.Access.public) | ||
model OrphanModel { | ||
@global.Azure.ClientGenerator.Core.clientName("modelName") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we do need to have a way to indicate how to serialize an orphan model. it seems weird that i have an orphan model that one property has a client name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And the eventgrid lib does exact this with But yes, we may need some way to say default to JSON, either argument to TCGC, option to emitter, or param to |
||
name: string; | ||
|
||
@encodedName("application/json", "desc") | ||
description: string; | ||
} | ||
Comment on lines
115
to
121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the model a little, to mix typespec name, client name, encoded name. And we expect SDK find the correct name for JSON serialization (it should be encoded name of application/json, if not available then typespec name). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the
unknown
to avoid ref theOrphanModel
.Let me know any language that having difficulty to serialize a
OrphanModel
model into the request body of this op.