Module

Yoga.HTTP.API.Route.OpenAPIMetadata

Package
purescript-yoga-http-api
Repository
rowtype-yoga/purescript-yoga-http-api

#HasFormat Source

class HasFormat ty  where

Members

Instances

#HasTitle Source

class HasTitle ty  where

Members

Instances

#HasEnum Source

class HasEnum ty  where

Members

Instances

#GenericEnumValues Source

class GenericEnumValues rep  where

Extract enum values from a Generic sum type representation. Walks through GR.Sum constructors and collects constructor names.

Members

Instances

#HasOperationMetadata Source

class HasOperationMetadata route  where

Members

Instances

#OperationMetadata Source

type OperationMetadata = { deprecated :: Boolean, description :: Maybe String, operationId :: Maybe String, summary :: Maybe String, tags :: Array String }

#Description Source

data Description :: Symbol -> Type -> Typedata Description desc a

Attach a description to a type. Example: Int # Description "The unique identifier for a user"

Instances

#Example Source

data Example :: Symbol -> Type -> Typedata Example exampleValue a

Attach an example value to a type. Example: Int # Example "123"

Instances

#Format Source

data Format :: Symbol -> Type -> Typedata Format formatStr a

Attach a format annotation to a type. Example: String # Format "email"

Instances

#Pattern Source

data Pattern :: Symbol -> Type -> Typedata Pattern pat a

Set a regex pattern constraint. Example: String # Pattern "^[a-z]+$"

Instances

#Title Source

data Title :: Symbol -> Type -> Typedata Title t a

Attach a title to a type. Example: String # Title "UserName"

Instances

#Default Source

data Default :: Symbol -> Type -> Typedata Default val a

Set a default value. Example: Int # Default "10"

Instances

#Enum Source

data Enum a

Wrapper to use an enum type (sum type with no-argument constructors) in routes. The type parameter should be a Generic sum type, and enum values will be automatically extracted from its constructor names.

Example: data Status = Pending | Active | Completed derive instance Generic Status _

type StatusParam = Enum Status

Instances

#Schema Source

data Schema :: Symbol -> Type -> Typedata Schema name a

Mark a type to be extracted as an OpenAPI component schema with $ref. When used in request/response bodies, generates a reference instead of inline schema.

Example: type User = { id :: Int, name :: String } Route POST path (Request { body :: JSON (Schema "User" User) }) (ok :: { body :: Schema "User" User })

Instances

#Callback Source

data Callback :: Type -> Symbol -> Symbol -> Type -> Type -> Row Type -> Typedata Callback inner name expression method requestBody responseRow

Define an OpenAPI callback for webhook/asynchronous API patterns. Callbacks allow you to define outgoing requests that your API will make to the client.

Parameters: inner - The wrapped type (transparent wrapper) name - The callback identifier (e.g., "onPaymentComplete") expression - The URL with runtime expressions (e.g., "{$request.body#/callbackUrl}") method - The HTTP method type for the callback (GET, POST, etc.) requestBody - The request body type for the callback responseRow - The response variants row for the callback

Example: type PaymentRoute = Route POST (Path (Lit "payment")) (Request { body :: JSON PaymentRequest }) ( ok :: { body :: PaymentResponse } ) # Callback "onPaymentComplete" "{$request.body#/callbackUrl}" POST (JSON { status :: String, transactionId :: String }) ( ok :: { body :: { received :: Boolean } } )

#type (#) Source

Operator alias for Yoga.HTTP.API.Route.OpenAPIMetadata.Callback (left-associative / precedence 5)

#type (:#) Source

Operator alias for Yoga.HTTP.API.Route.OpenAPIMetadata.Link (left-associative / precedence 5)

#Examples Source

data Examples :: Row Type -> Type -> Typedata Examples examplesRow a

Attach multiple named examples to a type for OpenAPI documentation. This allows you to provide several example values that will appear in the generated OpenAPI spec.

Example: Int # Examples (basic :: ExampleValue "42", advanced :: ExampleValue "100")

Instances

#ExampleValue Source

data ExampleValue :: Symbol -> Typedata ExampleValue value

A simple example with just a value (used in Examples row).

Example: basic :: ExampleValue "42"

#ExampleWithSummary Source

data ExampleWithSummary :: Symbol -> Symbol -> Typedata ExampleWithSummary value summary

An example with a summary (used in Examples row).

Example: premium :: ExampleWithSummary "456" "Premium user"

#ExampleObject Source

data ExampleObject :: Symbol -> Symbol -> Symbol -> Symbol -> Typedata ExampleObject value summary description externalValue

A complete example object with value, summary, description, and optional externalValue.

Example: external :: ExampleObject "" "External example" "An example from URL" "https://example.com/data.json"

#LinkMetadata Source

type LinkMetadata = { name :: String, operationId :: String, parameters :: Foreign }

Type for extracted link metadata