0

このリンクにリストされている手順(ステップ 5.1 まで) に従って、swagger ドキュメントを統合しました。以下は、私のコントローラークラスがどのように見えるかです。URL > http://localhost:8080/greetingservice/swagger-ui.htmlを使用してドキュメントに記載されている方法と同様のドキュメントにアクセスしようとすると、404 エラーが発生します。

ただし、URL http://localhost:8080/swagger-ui.html#!/greeting-controller/greetingUsingGETを使用してドキュメントが表示されます

アプリに固有のコンテキスト パスの下のドキュメントに記載されている方法と同様に、ドキュメントを表示したいと思います。不足しているものを教えてください。

import java.util.concurrent.atomic.AtomicLong;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.comcast.rapid.ctp.springfox.service.model.Greeting;

@RequestMapping("/greetingservice")
@RestController
public class GreetingController {

    private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

    @RequestMapping(method={RequestMethod.GET}, value="{apiName}", produces=MediaType.APPLICATION_JSON_VALUE)
    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name,@PathVariable String apiName) {
        return new Greeting(counter.incrementAndGet(),
                            String.format(template, name));
    }
}
4

1 に答える 1