@@ -1383,6 +1383,36 @@ func TestParseParamCommentByBodyTextPlain(t *testing.T) {
13831383 assert .Equal (t , expected , string (b ))
13841384}
13851385
1386+ // TODO: fix this
1387+ func TestParseParamCommentByBodyEnumsText (t * testing.T ) {
1388+ t .Parallel ()
1389+
1390+ comment := `@Param text body string true "description" Enums(ENUM1, ENUM2, ENUM3)`
1391+ operation := NewOperation (nil )
1392+
1393+ err := operation .ParseComment (comment , nil )
1394+
1395+ assert .NoError (t , err )
1396+ b , _ := json .MarshalIndent (operation .Parameters , "" , " " )
1397+ expected := `[
1398+ {
1399+ "description": "description",
1400+ "name": "text",
1401+ "in": "body",
1402+ "required": true,
1403+ "schema": {
1404+ "type": "string",
1405+ "enum": [
1406+ "ENUM1",
1407+ "ENUM2",
1408+ "ENUM3"
1409+ ]
1410+ }
1411+ }
1412+ ]`
1413+ assert .Equal (t , expected , string (b ))
1414+ }
1415+
13861416func TestParseParamCommentByBodyTypeWithDeepNestedFields (t * testing.T ) {
13871417 t .Parallel ()
13881418
@@ -1968,6 +1998,7 @@ func TestParseAndExtractionParamAttribute(t *testing.T) {
19681998 " default(1) maximum(100) minimum(0) format(csv)" ,
19691999 "" ,
19702000 NUMBER ,
2001+ "" ,
19712002 & numberParam ,
19722003 )
19732004 assert .NoError (t , err )
@@ -1976,38 +2007,39 @@ func TestParseAndExtractionParamAttribute(t *testing.T) {
19762007 assert .Equal (t , "csv" , numberParam .SimpleSchema .Format )
19772008 assert .Equal (t , float64 (1 ), numberParam .Default )
19782009
1979- err = op .parseParamAttribute (" minlength(1)" , "" , NUMBER , nil )
2010+ err = op .parseParamAttribute (" minlength(1)" , "" , NUMBER , "" , nil )
19802011 assert .Error (t , err )
19812012
1982- err = op .parseParamAttribute (" maxlength(1)" , "" , NUMBER , nil )
2013+ err = op .parseParamAttribute (" maxlength(1)" , "" , NUMBER , "" , nil )
19832014 assert .Error (t , err )
19842015
19852016 stringParam := spec.Parameter {}
19862017 err = op .parseParamAttribute (
19872018 " default(test) maxlength(100) minlength(0) format(csv)" ,
19882019 "" ,
19892020 STRING ,
2021+ "" ,
19902022 & stringParam ,
19912023 )
19922024 assert .NoError (t , err )
19932025 assert .Equal (t , int64 (0 ), * stringParam .MinLength )
19942026 assert .Equal (t , int64 (100 ), * stringParam .MaxLength )
19952027 assert .Equal (t , "csv" , stringParam .SimpleSchema .Format )
1996- err = op .parseParamAttribute (" minimum(0)" , "" , STRING , nil )
2028+ err = op .parseParamAttribute (" minimum(0)" , "" , STRING , "" , nil )
19972029 assert .Error (t , err )
19982030
1999- err = op .parseParamAttribute (" maximum(0)" , "" , STRING , nil )
2031+ err = op .parseParamAttribute (" maximum(0)" , "" , STRING , "" , nil )
20002032 assert .Error (t , err )
20012033
20022034 arrayParram := spec.Parameter {}
2003- err = op .parseParamAttribute (" collectionFormat(tsv)" , ARRAY , STRING , & arrayParram )
2035+ err = op .parseParamAttribute (" collectionFormat(tsv)" , ARRAY , STRING , "" , & arrayParram )
20042036 assert .Equal (t , "tsv" , arrayParram .CollectionFormat )
20052037 assert .NoError (t , err )
20062038
2007- err = op .parseParamAttribute (" collectionFormat(tsv)" , STRING , STRING , nil )
2039+ err = op .parseParamAttribute (" collectionFormat(tsv)" , STRING , STRING , "" , nil )
20082040 assert .Error (t , err )
20092041
2010- err = op .parseParamAttribute (" default(0)" , "" , ARRAY , nil )
2042+ err = op .parseParamAttribute (" default(0)" , "" , ARRAY , "" , nil )
20112043 assert .NoError (t , err )
20122044}
20132045
0 commit comments