Skip to content

fix(go-server): avoid AssertstringRequired for primitive-typed models#24374

Open
halfcrazy wants to merge 1 commit into
OpenAPITools:masterfrom
halfcrazy:fix/go-server-assertstring-and-ref-readonly
Open

fix(go-server): avoid AssertstringRequired for primitive-typed models#24374
halfcrazy wants to merge 1 commit into
OpenAPITools:masterfrom
halfcrazy:fix/go-server-assertstring-and-ref-readonly

Conversation

@halfcrazy

@halfcrazy halfcrazy commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

oneOf/nullable enums can flatten to string while still flagged as models, so templates must not emit Assertstring helpers that do not exist.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes go-server codegen to stop emitting Assertstring* helper calls for primitive-typed models (e.g., nullable oneOf enums). Prevents invalid references and compile errors in generated code.

  • Bug Fixes
    • Detects Go primitives and clears isModel to avoid generating non-existent Assertstring* helpers.
    • Updates model.mustache to skip Assert* calls when a property (or its items) is primitive.
    • Adds tests and a sample spec to verify no AssertstringRequired/Constraints are generated and AssertThingRequired is a no-op.

Written for commit 0b652fe. Summary will update on new commits.

Review in cubic

oneOf/nullable enums can flatten to *string while still flagged as models,
so templates must not emit Assertstring* helpers that do not exist.

Signed-off-by: Yan Zhu <hackzhuyan@gmail.com>
@halfcrazy

Copy link
Copy Markdown
Contributor Author

cc @antihax (2017/11) @grokify (2018/07) @kemokemo (2018/09) @jirikuncar (2021/01) @ph4r5h4d (2021/04) @lwj5 (2023/04)

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 4 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant