update for new dropshot pagination format (#465)
This commit is contained in:
parent
4f24250fe7
commit
87749a11ee
|
@ -89,6 +89,10 @@ struct BuilderImpl {
|
||||||
|
|
||||||
pub struct DropshotPagination {
|
pub struct DropshotPagination {
|
||||||
item: TypeId,
|
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 {
|
pub struct OperationParameter {
|
||||||
|
@ -1214,14 +1218,10 @@ impl Generator {
|
||||||
parameters: &[OperationParameter],
|
parameters: &[OperationParameter],
|
||||||
responses: &[OperationResponse],
|
responses: &[OperationResponse],
|
||||||
) -> Option<DropshotPagination> {
|
) -> Option<DropshotPagination> {
|
||||||
if operation
|
let Some(value) = operation.extensions.get("x-dropshot-pagination")
|
||||||
.extensions
|
else {
|
||||||
.get("x-dropshot-pagination")
|
|
||||||
.and_then(|v| v.as_bool())
|
|
||||||
!= Some(true)
|
|
||||||
{
|
|
||||||
return None;
|
return None;
|
||||||
}
|
};
|
||||||
|
|
||||||
// We expect to see at least "page_token" and "limit" parameters.
|
// We expect to see at least "page_token" and "limit" parameters.
|
||||||
if parameters
|
if parameters
|
||||||
|
@ -1316,7 +1316,21 @@ impl Generator {
|
||||||
.ok()?
|
.ok()?
|
||||||
.details()
|
.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,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -579,7 +579,9 @@
|
||||||
"$ref": "#/components/responses/Error"
|
"$ref": "#/components/responses/Error"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-dropshot-pagination": true
|
"x-dropshot-pagination": {
|
||||||
|
"required": []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/login": {
|
"/login": {
|
||||||
|
|
Loading…
Reference in New Issue