[BUG][RUBY-NEXTGEN] format: date properties stay String after from_hash

Open
#25,721 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Inf1mum is already working on this.

Since Nov 19, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
backend

Research direction

Start in the Ruby nextgen model code at Polymorphism.coerce and Polymorphism.cast_raw, where the issue says Time handling exists but Date handling is missing. Trace how from_hash converts a format: date property and how anyOf/oneOf candidates are matched. Add coverage for both cases; done when the property becomes a Date and the date candidate matches.

Written by the indexing model from the issue text.

Description

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

A format: date property is declared with type: 'Date', but neither Polymorphism.coerce nor Polymorphism.cast_raw has a Date branch (Time has one). The value is left as a String by from_hash, and a Date candidate of an anyOf/oneOf never matches.

openapi-generator version

master, 7.28.0-SNAPSHOT, 8a9fb722777e770e2c44b20b00bddbb51a0d525a

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: probes
  version: 1.0.0
paths:
  /greeting:
    get:
      operationId: getGreeting
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
  /pets:
    get:
      operationId: listPets
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
components:
  schemas:
    Pet:
      type: object
      properties:
        birthday:
          type: string
          format: date
        code:
          type: string
          pattern: '^[a-z]+$'
Generation Details
java -jar openapi-generator-cli.jar generate -g ruby-nextgen -i spec.yaml -o out \
  --additional-properties=gemName=petstore,moduleName=Petstore
Steps to reproduce
$LOAD_PATH.unshift 'out/lib'
require 'petstore'

pet = Petstore::Models::Pet.from_hash('birthday' => '2026-01-02')
p pet.birthday
p pet.birthday.class

Actual (ruby 4.0.9, faraday 2.15.1):

"2026-01-02"
String

Expected:

#<Date: 2026-01-02 ((2461043j,0s,0n),+0s,2299161j)>
Date
Related issues/PRs

Raised by the automated review of #25717; the code is already on master and is not changed by that PR.

Dominant language
Java
Stars
26.9k
Forks
7.8k
Avg merge
2d 23m
Merged PRs (30d)
177

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenAPITools/openapi-generator

All issues in OpenAPITools/openapi-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.