[Ruby] Nested resources are not using datatype defined in documentation.
cacique-coder opened this issue · 1 comments
cacique-coder commented
I am working with an API and the datatype is created correctly for c#
I have tried for Ruby and Typescript-fetch and it is returning generic values.
I can't see what I am doing wrong for Ruby or Typescript.
# documentation.yml
openapi: 3.0.3
info:
title: Testing
version: 2.0.0.alpha1
servers:
- url: https://www.lvh.me/api/v1
paths:
/now:
get:
summary: me
operationId: get_me
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/User"
components:
schemas:
Device:
type: object
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: "Device 1"
User:
type: object
properties:
devices:
type: array
items:
type: object
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: "Device 1"
number_of_devices_allowed:
type: integer
example: 20
description: Maximum of devices allowed for the current client
docker pull swaggerapi/swagger-codegen-cli-v3:3.0.42
docker run -it --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli-v3 generate \
-i /local/docs/api/tes.yml \
-l ruby \
-o /local/lib/test\
The data model generated for user looks like this:
require 'date'
module MobileDataAnywhere
class User
attr_accessor :devices
# Maximum of devices allowed for the current client
attr_accessor :number_of_devices_allowed
# Attribute type mapping.
def self.openapi_types
{
:'devices' => :'Object',
:'number_of_devices_allowed' => :'Object'
}
end
As a matter of fact, when the object is replaced manually to "Array", works perfectly.
machty commented
@cacique-coder I'm running into this as well for Ruby. All of the datatypes are defined as :Object:
when many of them should be :Array<MyDataType>: