Skip to content
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

Support default values for schema properties #66

Open
salminalex opened this issue Jun 13, 2023 · 3 comments · May be fixed by #649
Open

Support default values for schema properties #66

salminalex opened this issue Jun 13, 2023 · 3 comments · May be fixed by #649
Assignees
Labels
area/generator Affects: plugin, CLI, config file. area/openapi Adding/updating a feature defined in OpenAPI. size/M Medium task. (A couple of days of work.)
Milestone

Comments

@salminalex
Copy link

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:
Screenshot 2023-06-13 at 20 22 25

Current:
Screenshot 2023-06-13 at 20 20 58

Desired:
Screenshot 2023-06-13 at 20 21 52

@czechboy0
Copy link
Contributor

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.

@czechboy0 czechboy0 changed the title There is no default values for components. Support default values for struct properties Jun 13, 2023
@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. area/openapi Adding/updating a feature defined in OpenAPI. size/M Medium task. (A couple of days of work.) labels Jun 13, 2023
@simonjbeaumont simonjbeaumont changed the title Support default values for struct properties Support default values for schema properties Jun 13, 2023
@czechboy0 czechboy0 added this to the Post-1.0 milestone Aug 25, 2023
@PARAIPAN9
Copy link
Contributor

Hi, I would like to express my intention to work on this issue, if it is still available. Please let me know if I can proceed.

@czechboy0
Copy link
Contributor

Go ahead!

@PARAIPAN9 PARAIPAN9 linked a pull request Oct 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. area/openapi Adding/updating a feature defined in OpenAPI. size/M Medium task. (A couple of days of work.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants