Armeria(13)
오늘 한 것
- 컨트리뷰터의 오랜만에 코드리뷰 대응
I found a couple of issues in the generated JSON schema:
There are many duplicate definitions because each method has its own ID and definitions.
[
{
"$id": "...",
"definitions": { ... } // duplicate definitions
},
{
"$id": "...",
"definitions": { ... } // duplicate definitions
}
]
The "Cat" and "Dog" definitions are missing the species property, which is causing Autocomplete to fail.
To address this, I propose the following:
Use a root object with "$defs/methods" and "$defs/models" to put all methods and structs a single time.
It's worth noting that "definitions" is deprecated, as mentioned in the JSON Schema draft specification. https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-00#rfc.appendix.G
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "...",
"title": "...",
"$defs": {
"methods": {
"processAnimal": {
"$id": "com.linecorp.armeria.server.docs.PolymorphismDocServiceTest$AnimalService/processAnimal/POST",
"title": "processAnimal",
"type": "object",
"properties": {
"animal": {
"$ref": "#/$defs/models/Animal"
}
},
"required": [ "animal" ]
},
"processZoo": {
...
}
},
"models": {
"Animal": {
"type": "object",
"oneOf": [
{ "$ref": "#/$defs/models/Dog" },
{ "$ref": "#/$defs/models/Cat" }
],
"discriminator": {
"propertyName": "species",
"mapping": {
"dog": "#/$defs/models/Dog",
"cat": "#/$defs/models/Cat"
}
}
},
"Cat": {
"type": "object",
"properties": {
"species": { "type": "string" },
"name": { "type": "string" },
"likesTuna": { "type": "boolean" },
"scratchPost": { "$ref": "#/$defs/models/Toy" },
"vetRecord": { "$ref": "#/$defs/models/VetRecord" }
},
"required": [ "name", "likesTuna", "scratchPost", "vetRecord" ]
},
"Dog": {
...
},
...
}
}
}
Update RequestBody.tsx to align with the new schema format. (I might help you if you are not familiar with the frontend)
Please, let me know your opinion. 🙇
그래서 구현을 하긴 했는데, gRPC와 연관된 다른 부분에서 에러가 생겨서 어떻게 할지 물어보러 함.