swift-openapi-generator
swift-openapi-generator copied to clipboard
Support default values for schema properties
The generator skips the default values for Components.Schemas. It would be nice to have a default value for the property itself and in the initializer. I made an example:
Spec example:
Current:
Desired:
Thanks for filing it – you're right, default values are not generated at the moment, but it's a feature we'd like to do, and would gladly accept a pull request for 🙂 Let me slightly rename and label this issue, to properly track it.
A good starting point for anyone contributing this feature would be to add the default value to https://github.com/apple/swift-openapi-generator/blob/main/Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateObjectStruct.swift#L62, and work from there.