pub fn from_parameter(
parameter: Value,
options: &Options,
) -> Result<Value, Error>Expand description
Convert an OpenAPI 3.0 Parameter Object or Response Object.
With a schema member the result is a single JSON Schema. With a content
member the result is a map keyed by MIME type, where each value is a JSON
Schema with its own $schema. The outer map has no $schema.
A truthy description on the parameter is copied onto each result.
§Errors
Returns Error::InvalidInput when strict mode is on and the parameter has
neither a schema nor a content member. Returns Error::InvalidType
under the same conditions as from_schema.
§Example
use openapi_schema_to_json_schema::{from_parameter, Options};
use serde_json::json;
let param = json!({
"name": "id",
"in": "query",
"schema": { "type": "string", "nullable": true }
});
let out = from_parameter(param, &Options::new()).unwrap();
assert_eq!(out["type"], json!(["string", "null"]));