From 9e570dc1bfffde4ea1a9065d169a5c522ecbc033 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Wed, 4 Oct 2023 01:45:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Media=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=89=E3=81=AE=E3=82=A8=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=9D=E3=82=A4=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 + .../mastodon/MastodonMediaApiController.kt | 19 +++++++++ src/main/resources/openapi/mastodon.yaml | 41 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 src/main/kotlin/dev/usbharu/hideout/controller/mastodon/MastodonMediaApiController.kt diff --git a/build.gradle.kts b/build.gradle.kts index f88635b8..4b91b4f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,6 +60,8 @@ tasks.create("openApiGenerateMastodonCompatibleApi", GenerateTask: configOptions.put("interfaceOnly", "true") configOptions.put("useSpringBoot3", "true") additionalProperties.put("useTags", "true") + importMappings.put("org.springframework.core.io.Resource", "org.springframework.web.multipart.MultipartFile") + typeMappings.put("org.springframework.core.io.Resource", "org.springframework.web.multipart.MultipartFile") } repositories { diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/mastodon/MastodonMediaApiController.kt b/src/main/kotlin/dev/usbharu/hideout/controller/mastodon/MastodonMediaApiController.kt new file mode 100644 index 00000000..e1951898 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/mastodon/MastodonMediaApiController.kt @@ -0,0 +1,19 @@ +package dev.usbharu.hideout.controller.mastodon + +import dev.usbharu.hideout.controller.mastodon.generated.MediaApi +import dev.usbharu.hideout.domain.mastodon.model.generated.MediaAttachment +import org.springframework.http.ResponseEntity +import org.springframework.stereotype.Controller +import org.springframework.web.multipart.MultipartFile + +@Controller +class MastodonMediaApiController : MediaApi { + override fun apiV1MediaPost( + file: MultipartFile, + thumbnail: MultipartFile?, + description: String?, + focus: String? + ): ResponseEntity { + + } +} diff --git a/src/main/resources/openapi/mastodon.yaml b/src/main/resources/openapi/mastodon.yaml index 5464a28a..6f93fa36 100644 --- a/src/main/resources/openapi/mastodon.yaml +++ b/src/main/resources/openapi/mastodon.yaml @@ -17,6 +17,8 @@ tags: description: instance - name: timeline description: timeline + - name: media + description: media paths: /api/v2/instance: @@ -291,9 +293,48 @@ paths: type: array items: $ref: "#/components/schemas/Status" + /api/v1/media: + post: + tags: + - media + security: + - OAuth2: + - "write:media" + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: "#/components/schemas/V1MediaRequest" + encoding: + file: + contentType: image/jpeg, image/png + responses: + 200: + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/MediaAttachment" components: schemas: + V1MediaRequest: + type: object + properties: + file: + type: string + format: binary + thumbnail: + type: string + format: binary + description: + type: string + focus: + type: string + required: + - file + AccountsCreateRequest: type: object properties: