Skip to content

[BUG][RUBY] Property named ObjectId generates attr_accessor :object_id, overriding Object#object_id #25174

Closed

Description

@corsonknowles

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

When a schema has a property called ObjectId or object_id, the ruby client generator emits attr_accessor :object_id on the model. That overrides Object#object_id, which Ruby uses for object identity. Ruby warns about it at load time:

warning: redefining 'object_id' may cause serious problems

On Ruby 3.4 this warning prints by default, so every app that loads such a gem gets it, even without -W. It's also a real bug: anything that relies on object_id (identity-keyed caches, ObjectSpace._id2ref, debuggers) gets the API field value back instead of the object's id. Before the attribute is set, it gets nil.

object_id isn't in the Ruby generator's reserved words list. send was added to that list for the same reason in #3146. The Crystal generator added object_id in #22577.

openapi-generator version

Current master (7.27.0-SNAPSHOT). This isn't a regression; the reserved list has never included object_id.

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: object_id repro
  version: 1.0.0
paths: {}
components:
  schemas:
    Association:
      type: object
      properties:
        ObjectId:
          type: string
          format: uuid
Generation Details
openapi-generator generate -g ruby -i repro.yaml -o out
Steps to reproduce
  1. Generate with the spec above.
  2. out/lib/openapi_client/models/association.rb contains attr_accessor :object_id.
  3. ruby -Iout/lib -e 'require "openapi_client"' prints the warning.

Expected: the accessor is escaped like other reserved words (_object_id), and the JSON key stays ObjectId through attribute_map.

Related issues/PRs
Suggest a fix

Add object_id to the reserved words in RubyClientCodegen, next to send. PR to follow.

Activity

  1. added a commit that references this issue on Oct 8, 2026
    f2697e5
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions