OpenAPITools / OpenAPITools/openapi-generator
[aspnetcore] Setting properties of a model in server that are readOnly for client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I am working on a project that uses a generated C# ASP.NET core server-stub. The project is on .NET 6. There are a number of parameters in the API that are specified as readOnly: true for the client. However on the serverside I do want to write these fields. The model template assigns these parameters a private set. How am I supposed to write in this case? There is also no constructor.
openapi-generator version
v5.1.0
Suggest a fix/enhancement
Temporary solution to this problem is to customize the template and remove the private attribute. I would prefer however not to do this and use the defaults instead. Is this a potential bug or am I missing something here?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/openapi-generator/src/main/resources/aspnetcore/3.0/model.mustache at the referenced line and inspect how readOnly properties are generated in the C# ASP.NET Core server stub. Reproduce the generated model with the issue's .NET 6 and OpenAPI Generator v5.1.0 context, then determine the expected server-side assignment behavior and verify the generated output without a customized template.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100