swagger-api / swagger-api/swagger-codegen

undefined method build_from_hash in Enum data type

Open
#4,848 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Ruby Feature: Enum help wanted Issue: Bug Issue: Workaround available
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi, Im having an issue.
I am generating a json swagger into a ruby gem, the swagger JSOn contains Enum data type.
The generated class that has an Enum data type does not have build_from_hash method so it always get NoMethodError. the convert_to_type method always call build_from_hash method

this is the convert_to_type method

screen shot 2017-02-24 at 9 09 23 pm

this is the AccountCategory class that has Enum data type

screen shot 2017-02-24 at 9 09 39 pm

can somebody help me?

Contributor guide

Open the contributing guide

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.

Research direction

Reproduce generation with the Swagger JSON containing an enum, then trace the generated Ruby code from convert_to_type and compare AccountCategory with generated classes that define build_from_hash. Done means enum data types can be converted without raising NoMethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.