sunabak0 / akiyadego-kotlin

https://sunabak0.github.io/akiyadego-kotlin/
0 stars 0 forks source link

【調査タスク】 SpringBoot で Cookie を操作方法を学ぶ #74

Open sunakan opened 1 year ago

sunakan commented 1 year ago

触り

Spring BootでHTTPセッションをあつかう3つのパターン

によると、

の3種があるらしい

sunakan commented 1 year ago

OpenAPI Generator + Kotlin SpringBootではまだっぽい

https://github.com/OpenAPITools/openapi-generator/issues/12976

↓がうまく生成されない

securitySchemes:
  cookieAuth:
        type: apiKey
        in: cookie
        name: token

https://github.com/OpenAPITools/openapi-generator/issues/10008

https://gist.github.com/puneetugru/ec65183b4ad2da3ee8a7b43def2eea4a

コミット

貢献するための勉強が必要そう

sunakan commented 1 year ago

Documentation for the kotlin-spring Generator

https://openapi-generator.tech/docs/generators/kotlin-spring/

Parameter Feature

Cookie はサポートしているとある

sunakan commented 1 year ago

これではうまく行かない

openapi: '3.0.2'
info:
  title: 空き家で Go の URL 一覧
  version: '1.0'
servers:
  - url: https://akiyadego.com

paths:
  /top:
    get:
      description: '全投稿一覧'
      operationId: AllPost
      parameters:
        - in: cookie
          name: hogehoge
          schema:
            type: string
      security:
        - cookieAuth: []
      responses:
        '200':
          ....

components:
  securitySchemes:
    cookieAuth:
      type: apiKey
      in: cookie
      name: hogehoge
sunakan commented 1 year ago

SpringBoot使ってる場合はHttpSessionを@Autowiredできる

sunakan commented 1 year ago
    public String test(
            @CookieValue(name = "hoge", required = false) String hoge
    ) {
        return hoge;
    }

こういうのが生成されて欲しい