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

Check for missed fields #114

Closed zhulik closed 8 years ago

zhulik commented 8 years ago

Hi, it's me again=) lurker is works for me, but i note, that when i remove some fields from my api lurker specs stay green. But, when i add some new field - lurker tests is red. Is it valid behavior? How to check removed fields?

razum2um commented 8 years ago

It's defaults: as in readme:

Feel free to edit |schemas| according to json-schema standard, |they| can be very strict and flexible if you wish

there are keys additionalProperties and required in schema which should allow to tune adding and removing fields

the choice not to mark everything under required is still questionable and done when trying to share same schema (without using suffixes) across everything: I didn't want to setup database before every single spec-request to get full-futured api-result, so the amount of red results when lurking bunch of specs was frustrating

later I tend to lurk only the most valuable request-response pair and use suffixes, but it's also far from ideal :)

try to use it more and probably come up with ideas how to improve it :)

zhulik commented 8 years ago

@razum2um, thanks! So i need to change yml files by hands? Maybe adding some configuration flag for specs is good idea? Something like this for rspec

it 'list users', lurker: { required: :all } do
  get '/api/users'
end
razum2um commented 8 years ago

So i need to change yml files by hand

the more you invest into json-schema the more payback ;)

lurker: { required: :all }

maybe :) one thing to think about: this info is needed only when you intend to re/write schemas automatically, there was an idea of LURKER_UPGRADE flag (back to https://github.com/square/fdoc design), so maybe it should be env variable + you run only needed specs (rspec is cool at this)

@Strech @sponomarev what do you think?

sponomarev commented 8 years ago

required: :all is inappropriate, because we can't choose which properties are required, and which are not. YML scheme is enough here. But any upgrade option could be cool.

zhulik commented 8 years ago

@sponomarev :all is just an example, you can use [:array, :of, :fields], but, i supporse, for most cases, validation of all fields is preffered

sponomarev commented 8 years ago

@zhulik too much info about format in specs, which is just easy way to generate initial yml scheme imo

razum2um commented 8 years ago

@zhulik [:array, :of, :fields] when handling nesting we could end up with hiccup like style duplicating schemas in spec & yml :)

zhulik commented 8 years ago

@sponomarev, you right, too much info here is not good. But, when user need to generate schemas for 20-30 endpoinds with all fields required he must update every yml file.Too many time for it is not good too.

And this case not my=), just hypotetical

@razum2um, you right too, nesting will be ugly there