如何解决为什么这个 openapi 模式会生成不可用的 java/kotlin 客户端?
向全世界展示我是否错误地使用了 openapi(通过 micronaut kotlin 注释)。我的服务器生成的架构如下
openapi: 3.0.1
info:
title: WhyLabs Songbird
description: WhyLabs API that enables end-to-end AI observability
termsOfService: 'https://whylabs.ai/terms-of-use'
contact:
name: WhyLabs
url: 'https://whylabs.ai'
email: support@whylabs.ai
license:
name: Apache License 2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0'
version: '0.1'
paths:
'/v0/notification-settings/{org_id}':
get:
tags:
- Internal
- Notification Settings
summary: Get notification settings for an org
description: Get notification settings for an org
operationId: GetNotificationSettings
parameters:
- name: org_id
in: path
required: true
schema:
type: string
responses:
default:
description: GetNotificationSettings default response
content:
application/json:
schema:
$ref: '#/components/schemas/GetNotificationSettingsResponse'
security:
- ApiKeyAuth: []
post:
tags:
- Internal
- Notification Settings
summary: Update notification settings for an org
description: Update notification settings for an org
operationId: UpdateNotificationSettings
parameters:
- name: org_id
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NotificationSettings'
required: true
responses:
default:
description: UpdateNotificationSettings default response
content:
application/json:
schema:
$ref: '#/components/schemas/NotificationSettings'
security:
- ApiKeyAuth: []
components:
schemas:
NotificationSqsMessageCadence:
type: string
description: How often to deliver messages.
enum:
- DAILY
- WEEKLY
- INDIVIDUAL
DailySchedule:
type: object
properties:
cadence:
$ref: '#/components/schemas/NotificationSqsMessageCadence'
enabled:
type: boolean
local24HourOfDay:
type: integer
format: int32
localMinuteOfHour:
type: integer
format: int32
localTimezone:
type: string
description: A schedule that delivers all notifications as they come.
IndividualSchedule:
type: object
properties:
cadence:
$ref: '#/components/schemas/NotificationSqsMessageCadence'
enabled:
type: boolean
description: A schedule that delivers all notifications as they come.
NotificationSettingsDay:
type: string
enum:
- SUNDAY
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
WeeklySchedule:
type: object
properties:
cadence:
$ref: '#/components/schemas/NotificationSqsMessageCadence'
enabled:
type: boolean
dayOfWeek:
$ref: '#/components/schemas/NotificationSettingsDay'
local24HourOfDay:
type: integer
format: int32
localMinuteOfHour:
type: integer
format: int32
localTimezone:
type: string
description: A weekly schedule for how often to deliver notifications.
NotificationSchedule:
type: object
description: A schedule for how often to deliver notifications.
discriminator:
propertyName: cadence
mapping:
WEEKLY: '#/components/schemas/WeeklySchedule'
DAILY: '#/components/schemas/DailySchedule'
INDIVIDUAL: '#/components/schemas/IndividualSchedule'
oneOf:
- $ref: '#/components/schemas/WeeklySchedule'
- $ref: '#/components/schemas/DailySchedule'
- $ref: '#/components/schemas/IndividualSchedule'
NotificationSettings:
type: object
properties:
emailSettings:
$ref: '#/components/schemas/NotificationSchedule'
slackSettings:
$ref: '#/components/schemas/NotificationSchedule'
description: Settings that control how and when notifications are delivered.
GetNotificationSettingsResponse:
required:
- items
type: object
properties:
notificationSettings:
$ref: '#/components/schemas/NotificationSettings'
description: Response for getting notification settings
SubscriptionTier:
type: string
enum:
- FREE
- PAID
securitySchemes:
ApiKeyAuth:
type: apiKey
name: X-API-Key
in: header
如果您将其粘贴到 https://editor.swagger.io/ 处的在线 swagger 编辑器中,则相应的休息界面看起来很棒。有一个 UpdateNotificationSettings
api 接受 NotificationSettings
,其字段可以是以下三项之一:DailySchedule
、WeeklySchedule
和 IndividualSchedule
。
生成的打字稿客户端看起来不错。它直接将 NotificationSchedule
转换为联合类型,它实际上是。 java/kotlin 生成的客户端实际上无法使用,因为它们创建了子类型实际上并未继承的基本 NotificationSchedule
,这意味着您实际上无法使用 api。
我在规范中做错了什么还是这实际上是一个错误?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。