Skip to content

Support default values for schema properties #66

Open
@salminalex

Description

@salminalex

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

Activity

czechboy0

czechboy0 commented on Jun 13, 2023

@czechboy0
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.

changed the title [-]There is no default values for components.[/-] [+]Support default values for struct properties[/+] on Jun 13, 2023
added
area/generatorAffects: plugin, CLI, config file.
area/openapiAdding/updating a feature defined in OpenAPI.
size/MMedium task. (A couple of days of work.)
on Jun 13, 2023
changed the title [-]Support default values for struct properties[/-] [+]Support default values for schema properties[/+] on Jun 13, 2023
added this to the Post-1.0 milestone on Aug 25, 2023
PARAIPAN9

PARAIPAN9 commented on Sep 10, 2024

@PARAIPAN9
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

czechboy0 commented on Sep 10, 2024

@czechboy0
Contributor

Go ahead!

linked a pull request that will close this issue on Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/generatorAffects: plugin, CLI, config file.area/openapiAdding/updating a feature defined in OpenAPI.size/MMedium task. (A couple of days of work.)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @czechboy0@salminalex@PARAIPAN9

      Issue actions

        Support default values for schema properties · Issue #66 · apple/swift-openapi-generator