Azure / Azure/typespec-azure

[Bug]: ResourceCreateWIthServiceProvidedName should have a response body containing the resource

Open
#2,227 0 comments 0 reactions 0 assignees View on GitHub
feature lib:azure-core
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 21h
Merged PRs (30d)
164

Description

### Describe the bug

The ResourceCreateWithServiceProvidedName operation template currently creates an operation with a 201 response that has no defined response body.

```json
"responses": {
"201": {
"description": "The request has succeeded and a new resource has been created as a result.",
"headers": {
"Location": {
"type": "string",
"format": "uri",
"description": "The location of an instance of Widget"
}
}
},
```

This does not follow the Azure REST API Guidelines, specifically [this guideline](https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#http-return-resource):

![Image](https://github.com/user-attachments/assets/7a391dc6-3738-4954-9143-bf68c8aa65b5)

This operation template should be fixed to define a body in the 201 response with the same schema as the request body (the resource schema).

### Reproduction

[Playground link](https://azure.github.io/typespec-azure/playground/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZdmVyc2lvbmluZ8wfYXp1cmUtdG9vbHMvyCstxhVjb3JlIjsKCnVzaW5nIFR5cGVTcGVjLkh0dHA70BVSZXN00RVWyXLIG0HEWS5Db3Jl0hIuVHJhaXRzOwoKQHVzZUF1dGgoCiAgT8QJMsQFPFsKICAgIHvFBiAg5ACtOscfRmxvd8R2LmltcGxpY2l0LMclYXV0aG9yaXphdGlvblVybDogIuQBOXM6Ly9sb2dpbi5jb250b3NvLmNvbS9jb21tb24vb8Q1Mi92Mi4wL8hAZSLIUnNjb3BlczogW8lJd2lkZ2V0zUouZGVmYXVsdCJdxjd9CiAgXT4KKQpAc2VydmljZSjkAMZ0aXRsZTogIkPGOiBXxUkgTWFuYWdlciIsCn3HMWVy5AEKIntlbmRwb2ludH3HdOUAldA%2FQVBJc8UZxGMgIC8qKiAKU3Vw5AHvZWTIJVPmAIdzIMhTcyAocHJvdG9jb2wgYW5kIGhvc3RuYW1lLCBmb3IgZXhhbXBsZToK6QD0ZXN0dXMuYXBpLvIA%2FykuCiAqL8V%2ByF86IHN0cmluZ%2BQAmH3kAQjnAo1lZCjnAL8u5gCa5wD96AI7cykK5ACGc3BhY2Ug1So7CgrkAONUaMkg7wFIIOcBcyDHcy7kAJxlbnVtIMhk5QEqxEXHESAyMDIyLTA4LTMxxCwgIOQCkERlcGVuZGVuY3ko6wKzyEMudjFfMF9QcmV2aWV3XzIpCiAgYMlGMGAsCn0KCi8vIE1vZGVscyAv0wHmAMdBIOcBT8R5QHJlc291cmNlKCLGFnMiKQptxEPoAOPoALnkAP7GIyDkAS%2FFPiAgQGtlecg7TmFtZSLkAJdAdmlzaWJpbGl0eSgicmVhZMUWxDboAaQ7CtJWY29sb3LHV8UM1S1JRCBvZiB0yTcncyBtYW51ZmFjdHVyZchAzBNJZMpJ5gEjT3BlcuUDrvgBJ2FsaWFz6ALB5gQzID0gTm9SZXBlYXRhYmxlUmVxdWVzdHMgJgogIE5vQ29uZGnEUmFs0BpsaWVudMcVSWQ7yF3rAIQ97AShUucBkMogPO0AiD47CgppbnRlcmbkAq%2FmAaTmAl5jcmVhdGXGEiBpzGLJVUPHI3Rox1RQcm92aWRlZOQBuzzGOz7kASY%3D&e=%40azure-tools%2Ftypespec-autorest&options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40azure-tools%2Ftypespec-azure-rulesets%2Fdata-plane%22%5D%7D%7D)

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/azure/typespec-azure/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the [TypeSpec repo](https://github.com/Microsoft/TypeSpec/issues/new/choose)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Research direction

Start with the ResourceCreateWithServiceProvidedName operation template and reproduce the issue using the linked Playground example. Inspect the generated 201 response against the request resource schema and Azure REST API Guidelines. Done means the 201 response defines a body using the resource schema, while retaining the existing Location header.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.