razum2um / lurker

📖 The ultimate tool for documenting and testing APIs in Rails
https://lurker.razum2um.me/lurker
MIT License
116 stars 22 forks source link

Treat attribute `type` as Lurker::Json::Attribute #78

Closed Strech closed 10 years ago

Strech commented 10 years ago

If type not one of the following Json-Schema primitive, treat it as Lurker::Json::Attribute

array
boolean
integer
number
null
object
string
Strech commented 10 years ago

Example

obj = Lurker::Json::Object.new('name' => 'Foo')
obj.merge!('something' => { 'type' => 'Fail'})

Actual

---
description: ''
type: object
additionalProperties: false
required: []
properties:
  name:
    description: ''
    type: string
    example: Foo
  something:
    description: ''
    type: Fail
    example: ''

Expected

---
description: ''
type: object
additionalProperties: false
required: []
properties:
  name:
    description: ''
    type: string
    example: Foo
  something:
    description: ''
    type: object
    additionalProperties: false
    required: []
    properties:
      type:
        description: ''
        type: string
        example: Fail
razum2um commented 10 years ago

мда

Strech commented 10 years ago

@razum2um что? Сам YAML с вот таким кодом парсится отлично

properties:
  type:
    description: ''
    type: 'string'
    example: ''

Так что не все так плохо

Strech commented 10 years ago

И да, сейчас даже вот так работает:

obj = Lurker::Json::Object.new('name' => 'Foo')
obj.merge!('type' => 'Fail')
---
description: ''
type: object
additionalProperties: false
required: []
properties:
  name:
    description: ''
    type: string
    example: Foo
  type:
    description: ''
    type: string
    example: Fail