Closed PesiTheWizard closed 6 months ago
Thanks for reporting these inconsistencies. Fixed (1) and (4). soketVersion
from (1) serves no purpose in the public API for now, so I think it's fine to omit.
There's more. For example, a 200
response to /api/stream/event
is defined as
Picking one, GameStartEvent
is described as
which contains a GameEventInfo, which in turn is described as
However, looking at the gameStart
example from here
one discovers there are a lot more undocumented fields possibly returned by the API, for which the definition isn't know:
In addition, it's hard or impossible to discern when fields are nullable. Unfortunately these issues make it really hard to write a consistent client, and pretty much impossible to generate one with OpenAPI Generator. Is there a place in (presumably) the lila repository where more reliable information can be found for the moment?
Edit:
Also, the example structure isn't even correct: Here's a real json object received from the API. The compat
field isn't part of the challenge
object, unlike in the example:
{
"challenge": {
"challenger": { ... },
"color": "random",
"destUser": { ... },
"finalColor": "black",
"id": "GqB3EN2W",
"perf": { ... },
"rated": false,
"speed": "blitz",
"status": "created",
"timeControl": { ... },
"url": "https://lichess.org/GqB3EN2W",
"variant": { ... }
},
"compat": {
"board": true,
"bot": true
},
"type": "challenge"
}
Here's the example for a challenge:
Yes, the lila repository contains the real definitions. In many cases, there is a JsonView class/file which handles the serialization. For the events stream, it's done here: https://github.com/lichess-org/lila/blob/master/modules/api/src/main/EventStream.scala.
You are very welcome to contribute PRs to improve the specification. Having it accurate and complete enough to allow automatic client generation has been discussed a bit here and there and definitely would be really cool but so far nobody has had the time and interest to make major improvements in this area.
@benediktwerner Yeah, I got to EventStream.scala
yesterday also. I think the very manual way json is generated in lila is problematic for accurate documentation. To achieve accurate documentation, I think generating the API should be preferred, however, it looks like a massive effort. Just for describing the object schemas, you'd probably have to lift every returned json type into it's own data class, and annotate accordingly. When working in Spring, you can then annotate each rest method accordingly to generate an accurate API while generating the json from the data classes with Swagger.
In general, I think investing effort into automatic generation is worthwhile because it saves a lot of work and trouble in the long term.
It might be something I can contribute to, though I'm not versed in Scala at all unfortunately.
Hey all any reason why task 3 is not finished?
I can work on this
The above used a bot:play token