@@ -401,9 +401,52 @@ data ProposalResponse
401401 , proposalResponseCcAbstainVotes :: Integer
402402 , proposalResponsePrevGovActionIndex :: Maybe Integer
403403 , proposalResponsePrevGovActionTxHash :: Maybe HexText
404+ , proposalResponseAuthors :: Maybe ProposalAuthors
404405 }
405406 deriving (Generic , Show )
406407
408+ newtype ProposalAuthors = ProposalAuthors { getProposalAuthors :: Value }
409+ deriving newtype (Show )
410+
411+ instance FromJSON ProposalAuthors where
412+ parseJSON v@ (Array _) = pure $ ProposalAuthors v
413+ parseJSON _ = fail " ProposalAuthors must be a JSON array"
414+
415+ instance ToJSON ProposalAuthors where
416+ toJSON (ProposalAuthors v) = v
417+
418+ instance ToSchema ProposalAuthors where
419+ declareNamedSchema _ = pure $ NamedSchema (Just " ProposalAuthors" ) $ mempty
420+ & type_ ?~ OpenApiArray
421+ & description ?~ " A JSON array of proposal authors"
422+ & example ?~ toJSON
423+ [ object
424+ [ " name" .= (" Alice" :: Text )
425+ , " witnessAlgorithm" .= (" algo" :: Text )
426+ , " publicKey" .= (" key" :: Text )
427+ , " signature" .= (" sig" :: Text )
428+ ]
429+ , object
430+ [ " name" .= (" Bob" :: Text )
431+ , " witnessAlgorithm" .= (" algo2" :: Text )
432+ , " publicKey" .= (" key2" :: Text )
433+ , " signature" .= (" sig2" :: Text )
434+ ]
435+ ]
436+
437+ exampleProposalAuthors :: Text
438+ exampleProposalAuthors =
439+ " [\
440+ \ {\" name\" : \" Alice\" ,\
441+ \ \" witnessAlgorithm\" : \" Ed25519\" ,\
442+ \ \" publicKey\" : \" abcdef123456\" ,\
443+ \ \" signature\" : \" deadbeef\" },\
444+ \ {\" name\" : \" Bob\" ,\
445+ \ \" witnessAlgorithm\" : \" Ed25519\" ,\
446+ \ \" publicKey\" : \" 123456abcdef\" ,\
447+ \ \" signature\" : \" beefdead\" }\
448+ \]"
449+
407450deriveJSON (jsonOptions " proposalResponse" ) ''ProposalResponse
408451
409452exampleProposalResponse :: Text
@@ -433,7 +476,9 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
433476 <> " \" cCNoVotes\" : 0,"
434477 <> " \" cCAbstainVotes\" : 0,"
435478 <> " \" prevGovActionIndex\" : 0,"
436- <> " \" prevGovActionTxHash\" : \" 47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\" }"
479+ <> " \" prevGovActionTxHash\" : \" 47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\" ,"
480+ <> " \" authors\" : " <> exampleProposalAuthors
481+ <> " }"
437482
438483instance ToSchema Value where
439484 declareNamedSchema _ = pure $ NamedSchema (Just " Value" ) $ mempty
0 commit comments