[Swagger] Springdoc setting

N'CHE·2022년 6월 24일
0

Add springdoc settings and environment variable

Springdoc settings honey tip 🍯

The supported-submit-methods array contains 'get', 'post', 'patch', 'put', 'delete', 'options'.
But if you leave an empty array, you can't try-out API, only use swagger as a API document.
Disable try-out feature is not officially supported, so you can use it as a trick.😋

springdoc:
  swagger-ui:
    supported-submit-methods: []

Environment variable

  • They can be binding ☺ so I use the version property is environment ~ global🌏 ~ variable.
api:
 version: v1
private static String VERSION;

@Value("${api.version}")
private void setVERSION(String version){
    VERSION = version;
}

Create OpenAPI configuration bean 🫘

I found it a bit disappointing.
I tried to set up multiple external documents information.
Because method call chain is continuously possible.
But it only supported only one url and description set last.
Of course.
It's like a builder chain doing setter things.
I just kept overwriting the values. 😂

public ExternalDocumentation springdocDoc(){
  return new ExternalDocumentation()
            .description("aaadocs")
            .url("https://aaa.docs/");
}
public class ExternalDocumentation {
  private String description = null;
  private String url = null;

  public ExternalDocumentation url(String url) {
      this.url = url;
      return this;
  }
  public ExternalDocumentation description(String description) {
      this.description = description;
      return this;
  }
/* ellipsis */
}

0개의 댓글