2017-08-04 18 views
0

こんにちは私は残りのAPIを持っていて、このAPIのテストにswaggerを使用しました。スワッガーで可能な値をドロップダウンする方法

以下は私のAPIの1つです。

@RequestMapping(value = "/api/test", method = RequestMethod.POST) 
public void test(String string){ 
    // body 
} 

「データベース」または「キャッシュ」の可能な値は、「データベース」または「キャッシュ」です。

だから私はぼんやりとした表示にしたい。

私はGoogleの検索を行って、私はどのようにjavaで実装するための方法を見つけることができません。

答えて

1

であなたのパラメータに注釈を付けることができます。参照以下を参照してください。以下

@RequestMapping(value = "/api/test", method = RequestMethod.POST) 
public void test(TestEnum enum) { 
    // body 
} 

そして、あなたのTestEnumです:

public enum TestEnum { 

    Dropdown1("DropDown1"), 
    DropDown2("DropDown2"); 

    private String str; 

    TestEnum(String str){ 
     this.str = str; 
    } 

    public String getStr() { 
     return str; 
    } 
} 
0

あなたが代わりに文字列のあなたのメソッドの引数として列挙を使用する必要が取り得る値

@RequestMapping(value = "/api/test", method = RequestMethod.POST) 
public void test(@ApiParam(allowableValues = "one, two, three") String string) { 
    // body 
} 
+0

その動作していない、そこにあるテキスト領域の代わりにドロップダウンの表示です。 –

関連する問題