Skip to content

Instantly share code, notes, and snippets.

@sojw
Last active August 5, 2019 02:09
Show Gist options
  • Save sojw/d8c55001b28d838a096c3256d4b1a7ac to your computer and use it in GitHub Desktop.
Save sojw/d8c55001b28d838a096c3256d4b1a7ac to your computer and use it in GitHub Desktop.

Revisions

  1. sojw revised this gist Jun 17, 2016. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions SampleApiContorller.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    @Api(value = "Some API")
    @RestController
    @RequestMapping(value = "/Service")
    public class SampleApiContorller {
    @Autowired
    private ResponseEntityUtil responseEntityUtil;

    @Autowired
    private ServiceApiProxyFactory serviceApiProxyFactory;

    @ApiOperation(value = "Category List API", notes = "get some list ", response = Category.class, responseContainer = "List")
    @RequestMapping(value = {"/CategoryList.json"}, produces = Type.JSON_UTF8, method = RequestMethod.GET)
    public ResponseEntity<?> legacyCategoryList(
    @ApiParam(value = "service id", required = true) @RequestParam("serviceId") String serviceId,
    @ApiParam(hidden = true) @ModelAttribute("loginInfo") LoginInfo loginInfo) throws Exception {
    List<Category> categories = serviceApiProxyFactory.getCategoryList(loginInfo.getId());
    return responseEntityUtil.success(categories);
    }
    }
  2. sojw revised this gist Jun 17, 2016. No changes.
  3. sojw revised this gist Jun 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SpringMvcConfiguration.java
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    @ComponentScan(basePackages = "com.naver", useDefaultFilters = false, includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class),
    @ComponentScan.Filter(type = FilterType.ANNOTATION, value = ControllerAdvice.class)})
    @Import({CoreApplicationContextConfiguration.class, SwaggerConfig.class})
    public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
    public class SpringMvcConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
  4. sojw revised this gist Jun 17, 2016. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions SpringMvcConfiguration.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    @Configuration
    @EnableWebMvc
    @EnableSwagger2
    @ComponentScan(basePackages = "com.naver", useDefaultFilters = false, includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class),
    @ComponentScan.Filter(type = FilterType.ANNOTATION, value = ControllerAdvice.class)})
    @Import({CoreApplicationContextConfiguration.class, SwaggerConfig.class})
    public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/static/**").addResourceLocations("/static/");
    // swagger 설정
    registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
    }
  5. sojw revised this gist Jun 17, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions SwaggerConfiguration.java
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,15 @@ public class SwaggerConfiguration {
    @Bean
    public Docket documentation() {
    return new Docket(DocumentationType.SWAGGER_2).select().apis(
    RequestHandlerSelectors.basePackage("com.naver.plug.api.v1.cafe")).paths(PathSelectors.any()).build().pathMapping(
    RequestHandlerSelectors.basePackage("api.class.packagename")).paths(PathSelectors.any()).build().pathMapping(
    "/").apiInfo(apiInfo());
    }
    @Bean
    UiConfiguration uiConfig() {
    return new UiConfiguration("validatorUrl");
    }
    private ApiInfo apiInfo() {
    return new ApiInfo("PLUG API", "PLUG API 명세서", "1.0", "My Apps API terms of service",
    return new ApiInfo("Swagger API", "Swagger API Desc", "1.0", "My Apps API terms of service",
    "[email protected]", "", "");
    }
    }
  6. sojw revised this gist Jun 17, 2016. No changes.
  7. sojw created this gist Jun 17, 2016.
    18 changes: 18 additions & 0 deletions SwaggerConfiguration.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    @Configuration
    @EnableSwagger2
    public class SwaggerConfiguration {
    @Bean
    public Docket documentation() {
    return new Docket(DocumentationType.SWAGGER_2).select().apis(
    RequestHandlerSelectors.basePackage("com.naver.plug.api.v1.cafe")).paths(PathSelectors.any()).build().pathMapping(
    "/").apiInfo(apiInfo());
    }
    @Bean
    UiConfiguration uiConfig() {
    return new UiConfiguration("validatorUrl");
    }
    private ApiInfo apiInfo() {
    return new ApiInfo("PLUG API", "PLUG API 명세서", "1.0", "My Apps API terms of service",
    "[email protected]", "", "");
    }
    }