All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.simiacryptus.skyenet.util.OpenAPI.kt Maven / Gradle / Ivy

There is a newer version: 1.2.21
Show newest version
package com.simiacryptus.skyenet.util

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue

// OpenAPI root document
data class OpenAPI(
    val openapi: String = "3.0.0",
    val info: Info? = null,
    val paths: Map? = emptyMap(),
    @JsonInclude(JsonInclude.Include.NON_NULL)
    val components: Components? = null
)

// Metadata about the API
data class Info(
    val title: String? = null,
    val version: String? = null,
    val description: String? = null,
    val termsOfService: String? = null,
    val contact: Contact? = null,
    val license: License? = null
)

// Contact information
data class Contact(
    val name: String? = null,
    val url: String? = null,
    val email: String? = null
)

// License information
data class License(
    val name: String? = null,
    val url: String? = null
)

// Paths and operations
data class PathItem(
    val get: Operation? = null,
    val put: Operation? = null,
    val post: Operation? = null,
    val delete: Operation? = null,
    val options: Operation? = null,
    val head: Operation? = null,
    val patch: Operation? = null
)

// An API operation
data class Operation(
    val summary: String? = null,
    val description: String? = null,
    val responses: Map? = emptyMap(),
    val parameters: List? = emptyList(),
    val operationId: String? = null,
    val requestBody: RequestBody? = null,
    val security: List>>? = emptyList(),
    val tags: List? = emptyList(),
    val callbacks: Map? = emptyMap(),
    val deprecated: Boolean? = null,
)

// Operation response
data class Response(
    val description: String? = null,
    @JsonInclude(JsonInclude.Include.NON_NULL)
    val content: Map? = emptyMap()
)

// Components for reusable objects
data class Components(
    val schemas: Map? = emptyMap(),
    val responses: Map? = emptyMap(),
    val parameters: Map? = emptyMap(),
    val examples: Map? = emptyMap(),
    val requestBodies: Map? = emptyMap(),
    val headers: Map? = emptyMap(),
    val securitySchemes: Map? = emptyMap(),
    val links: Map? = emptyMap(),
    val callbacks: Map? = emptyMap()
)

// Simplified examples of component objects
data class Schema(
    val type: String? = null,
    val properties: Map? = emptyMap(),
    val items: Schema? = null,
    val `$ref`: String? = null,
    val format: String? = null,
    val description: String? = null,

    )

data class Parameter(
    val name: String? = null,
    val `in`: String? = null,
    val description: String? = null,
    val required: Boolean? = null,
    val schema: Schema? = null,
    val content: Map? = null,
    val example: Any? = null,
)

data class Example(val summary: String? = null, val description: String? = null)
data class RequestBody(val description: String? = null, val content: Map? = null)
data class Header(val description: String? = null)
data class SecurityScheme(val type: String? = null, val description: String? = null)
data class Link(val operationId: String? = null)
data class Callback(val expression: String? = null)
data class MediaType(val schema: Schema? = null)





© 2015 - 2024 Weber Informatics LLC | Privacy Policy