Skip to content

feat: support enums#18

Merged
Brendan Le Glaunec (Ullaakut) merged 3 commits intomainfrom
16-enum-support
May 5, 2025
Merged

feat: support enums#18
Brendan Le Glaunec (Ullaakut) merged 3 commits intomainfrom
16-enum-support

Conversation

@Ullaakut
Copy link
Copy Markdown
Member

Goal of this PR

Fixes #16

This PR adds support for the enum directive.

How did I test it?

Updated the unit tests.

This comment was marked as outdated.

fix: add missing newline at end of generated file & reorder fields
@nrwiersma
Copy link
Copy Markdown
Contributor

Looks fine, but you are missing the application of this in gen.go.

@Ullaakut

This comment was marked as outdated.

@nrwiersma
Copy link
Copy Markdown
Contributor

You are not using the Enums function that is generated, so it never really ends up in the spec.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the new enum directive, enabling enum values to be specified and applied to schema properties.

  • Introduces a new enumerable interface and associated applyEnums function in gen.go and updates the customizer.
  • Updates test files to include enum declarations and adds generated output for enums in templates.

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
gen_test.go Added a new test method for enums
gen.go Introduced enumerable interface and applyEnums function
cmd/oapi-gen/testdata/test.go Added enum directive comment for testing
cmd/oapi-gen/testdata/all.go Extended test object with enum values
cmd/oapi-gen/gen.go Implemented parsing and template generation support for enum directives
Files not reviewed (2)
  • testdata/spec-pkgseg0.json: Language not supported
  • testdata/spec.json: Language not supported

Comment thread cmd/oapi-gen/testdata/test.go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick.

Comment thread gen.go Outdated
Co-authored-by: Nicholas Wiersma <nick@wiersma.co.za>
@Ullaakut Brendan Le Glaunec (Ullaakut) merged commit c690f86 into main May 5, 2025
14 checks passed
@Ullaakut Brendan Le Glaunec (Ullaakut) deleted the 16-enum-support branch May 5, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support enum values

3 participants