Fix getOpenSubsonicExtensions endpoint

Match the current doc: https://opensubsonic.netlify.app/docs/endpoints/getopensubsonicextensions/

openSubsonicExtensions must be an array, not a struct
This commit is contained in:
Deluan 2023-11-27 13:25:06 -05:00
parent 60a5fbe1fe
commit f543e7accc
6 changed files with 68 additions and 2 deletions

View File

@ -0,0 +1,16 @@
{
"status": "ok",
"version": "1.8.0",
"type": "navidrome",
"serverVersion": "v0.0.0",
"openSubsonic": true,
"openSubsonicExtensions": [
{
"name": "template",
"versions": [
1,
2
]
}
]
}

View File

@ -0,0 +1,6 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<openSubsonicExtensions name="template">
<versions>1</versions>
<versions>2</versions>
</openSubsonicExtensions>
</subsonic-response>

View File

@ -0,0 +1,8 @@
{
"status": "ok",
"version": "1.8.0",
"type": "navidrome",
"serverVersion": "v0.0.0",
"openSubsonic": true,
"openSubsonicExtensions": []
}

View File

@ -0,0 +1 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true"></subsonic-response>

View File

@ -424,13 +424,18 @@ type JukeboxPlaylist struct {
JukeboxStatus
Entry []Child `xml:"entry,omitempty" json:"entry,omitempty"`
}
type OpenSubsonicExtensions struct{}
type OpenSubsonicExtension struct {
Name string `xml:"name,attr" json:"name"`
Versions []int32 `xml:"versions" json:"versions"`
}
type OpenSubsonicExtensions []OpenSubsonicExtension
// OpenSubsonic response type for multi-valued genres list
type ItemGenre struct {
Name string `xml:"name,attr" json:"name"`
}
// ItemGenres holds a list of genres (OpenSubsonic). If it is null, it must be marshalled as an empty array.
type ItemGenres []ItemGenre
func (i ItemGenres) MarshalJSON() ([]byte, error) {

View File

@ -725,6 +725,36 @@ var _ = Describe("Responses", func() {
})
})
Describe("OpenSubsonicExtensions", func() {
BeforeEach(func() {
response.OpenSubsonic = true
response.OpenSubsonicExtensions = &OpenSubsonicExtensions{}
})
Describe("without data", func() {
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
Describe("with data", func() {
BeforeEach(func() {
response.OpenSubsonicExtensions = &OpenSubsonicExtensions{
OpenSubsonicExtension{Name: "template", Versions: []int32{1, 2}},
}
})
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
})
Describe("InternetRadioStations", func() {
BeforeEach(func() {
response.InternetRadioStations = &InternetRadioStations{}