An Elixir toolkit for the AT Protocol. hexdocs.pm/atex
elixir bluesky atproto decentralization
25
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(deflexicon): wip

+38 -2
+2
CHANGELOG.md
··· 37 37 - Various improvements to `Atex.Did.Document` 38 38 - Add `Atex.DID.Document.Service` and `Atex.DID.Document.VerificationMethod` sub-structs. 39 39 - Add `to_json/1` methods and `JSON.Encoder` protocols for easy conversion to camelCase JSON. 40 + - `deflexicon` now emits `content_type/0` functions (on `Input` submodules for typed JSON bodies, 41 + otherwise on the root module) for procedures. 40 42 41 43 ### Fixed 42 44
+36 -2
lib/atex/lexicon.ex
··· 347 347 348 348 input = 349 349 if def[:input] && def.input[:schema] do 350 - [schema] = def_to_schema(nsid, "input", def.input.schema) 351 - schema 350 + encoding = def.input[:encoding] 351 + 352 + [{key, quoted_schema, quoted_type, quoted_struct}] = 353 + def_to_schema(nsid, "input", def.input.schema) 354 + 355 + quoted_struct = 356 + quote do 357 + unquote(quoted_struct) 358 + 359 + @spec content_type() :: String.t() 360 + def content_type, do: unquote(encoding) 361 + end 362 + 363 + {key, quoted_schema, quoted_type, quoted_struct} 364 + end 365 + 366 + # Add `content_type/0` to the root module if the lexicon defines a type without a schema. 367 + raw_input_encoding = 368 + if is_nil(input) && def[:input] do 369 + def.input[:encoding] 352 370 end 353 371 354 372 # Root struct containing `input`, `raw_input`, and `params` ··· 386 404 input -> 387 405 quote do 388 406 defstruct input: nil 407 + end 408 + 409 + params && raw_input_encoding -> 410 + quote do 411 + defstruct raw_input: nil, params: nil 412 + 413 + @spec content_type() :: String.t() 414 + def content_type, do: unquote(raw_input_encoding) 415 + end 416 + 417 + raw_input_encoding -> 418 + quote do 419 + defstruct raw_input: nil 420 + 421 + @spec content_type() :: String.t() 422 + def content_type, do: unquote(raw_input_encoding) 389 423 end 390 424 391 425 params ->