update for new dropshot pagination format (#465)

This commit is contained in:
Adam Leventhal 2023-05-08 11:16:48 -07:00 committed by GitHub
parent 4f24250fe7
commit 87749a11ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 9 deletions

View File

@ -89,6 +89,10 @@ struct BuilderImpl {
pub struct DropshotPagination {
item: TypeId,
// TODO this is going to be used by the SDK and CLI generation to validate
// inputs.
#[allow(unused)]
first_page_params: Vec<String>,
}
pub struct OperationParameter {
@ -1214,14 +1218,10 @@ impl Generator {
parameters: &[OperationParameter],
responses: &[OperationResponse],
) -> Option<DropshotPagination> {
if operation
.extensions
.get("x-dropshot-pagination")
.and_then(|v| v.as_bool())
!= Some(true)
{
let Some(value) = operation.extensions.get("x-dropshot-pagination")
else {
return None;
}
};
// We expect to see at least "page_token" and "limit" parameters.
if parameters
@ -1316,7 +1316,21 @@ impl Generator {
.ok()?
.details()
{
typify::TypeDetails::Vec(item) => Some(DropshotPagination { item }),
typify::TypeDetails::Vec(item) => {
#[derive(serde::Deserialize, Default)]
struct DropshotPaginationFormat {
required: Vec<String>,
}
let first_page_params = serde_json::from_value::<
DropshotPaginationFormat,
>(value.clone())
.unwrap_or_default()
.required;
Some(DropshotPagination {
item,
first_page_params,
})
}
_ => None,
}
}

View File

@ -579,7 +579,9 @@
"$ref": "#/components/responses/Error"
}
},
"x-dropshot-pagination": true
"x-dropshot-pagination": {
"required": []
}
}
},
"/login": {