Open OSRSBlue opened 1 year ago
Also happens for me too. Would love a response from the team. ❤️
If you don't want the properties to be optional you need to add them to the required
list. e.g.
"myObj": {
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"description": {
"type": "string",
"title": "Description"
}
},
"type": "object",
"required": [
"name",
"description"
],
"title": "MyObj"
},
Bug Report Checklist
Description
When I generate a typescript-axios client from my APIs written in GoLang all of the models properties are optional. I would expect all the fields to be non optional unless specified.
openapi-generator version
Library: @openapitools/openapi-generator-cli: 2.5.2
OpenAPI declaration file content or url
GoLang Model
Generated swag model from yaml file:
typescript-axios generated model from yaml file definition:
Generation Details
Building a typescript axios client using the command:
openapi-generator-cli generate -i specFile -g typescript-axios -o outputDir -p packageName
results in all my produced models from my GoLang swag generated definition to be optional. I would expect them to not be optional unless specified.
Steps to reproduce
Suggest a fix
I may be describing my models incorrectly, so this could just be user error. If this is a feature ask I would think that being able to set a golang tag on properties for if they are nullable or not to avoid having all option properties in the generated typescript-axios client models.
For example, you have this GoLang struct, which produces that yaml and typescript model to have all fields being non optional, but the current behavior is to have all the fields as optional. I would expect the generated model to match my last example where the fields are not optional.
typescript-axios generated model from yaml file definition:
This is my expected typescript-axios generated model from yaml file definition (All the properties are not optional):