feat(plugins): change websockets Data field type to []byte for binary support

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan
2026-03-02 16:38:00 -05:00
parent 30df004d4d
commit 6fd044fb09
10 changed files with 94 additions and 22 deletions
@@ -303,6 +303,45 @@ var _ = Describe("XTP Schema Generation", func() {
})
})
Context("capability with []byte field", func() {
It("should map []byte to string with byte format, not array", func() {
capability := Capability{
Name: "byte_test",
SourceFile: "byte_test",
Methods: []Export{
{ExportName: "test", Input: NewParam("input", "Input"), Output: NewParam("output", "Output")},
},
Structs: []StructDef{
{
Name: "Input",
Fields: []FieldDef{
{Name: "Data", Type: "[]byte", JSONTag: "data"},
},
},
{
Name: "Output",
Fields: []FieldDef{
{Name: "Value", Type: "string", JSONTag: "value"},
},
},
},
}
schema, err := GenerateSchema(capability)
Expect(err).NotTo(HaveOccurred())
Expect(ValidateXTPSchema(schema)).To(Succeed())
doc := parseSchema(schema)
components := doc["components"].(map[string]any)
schemas := components["schemas"].(map[string]any)
input := schemas["Input"].(map[string]any)
props := input["properties"].(map[string]any)
data := props["data"].(map[string]any)
Expect(data["type"]).To(Equal("string"))
Expect(data["format"]).To(Equal("byte"))
Expect(data).NotTo(HaveKey("items"))
})
})
Context("capability with nullable ref", func() {
It("should mark pointer to enum as nullable with $ref", func() {
capability := Capability{