Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <github@jessfraz.com>
  • Loading branch information
jessfraz committed Aug 12, 2024
1 parent 9c9e619 commit 7a15f91
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 71 deletions.
22 changes: 21 additions & 1 deletion openapitor/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,26 @@ pub(crate) fn get_schema_from_any(data: &SchemaData, any: &AnySchema) -> Option<
},
});
} else if let Some(typ) = &any.typ {
if typ == "array" {
if typ == "object" {
if let Some(format) = &any.format {
if format == "uri-map" {
return Some(openapiv3::Schema {
schema_data: data.clone(),
schema_kind: openapiv3::SchemaKind::Type(openapiv3::Type::Object(
openapiv3::ObjectType {
properties: any.properties.clone(),
required: any.required.clone(),
additional_properties: Some(openapiv3::AdditionalProperties::Any(
true,
)),
min_properties: any.min_properties,
max_properties: any.max_properties,
},
)),
});
}
}
} else if typ == "array" {
return Some(openapiv3::Schema {
schema_data: data.clone(),
schema_kind: openapiv3::SchemaKind::Type(openapiv3::Type::Array(
Expand All @@ -2409,6 +2428,7 @@ pub(crate) fn get_schema_from_any(data: &SchemaData, any: &AnySchema) -> Option<
)),
});
}

return Some(openapiv3::Schema {
schema_data: data.clone(),
schema_kind: openapiv3::SchemaKind::Type(openapiv3::Type::String(
Expand Down
28 changes: 12 additions & 16 deletions openapitor/tests/remote.json
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,7 @@
"work_address_is_home_address": "yes",
"years_of_experience": "2"
},
"country": {
"code": "AUT",
"name": "Austria"
},
"country_code": "AUT",
"created_at": "2021-11-11T18:44:39",
"emergency_contact_details": {
"email": "taylor@johnson.com",
Expand Down Expand Up @@ -544,10 +541,7 @@
},
"bank_account_details": {
"items": {
"description": "List of bank account information. Its properties may vary depending on the country.",
"type": "list",
"x-struct": null,
"x-validate": null
"description": "List of bank account information. Its properties may vary depending on the country."
},
"nullable": true,
"type": "array",
Expand All @@ -565,7 +559,14 @@
"contract_details": {
"$ref": "#/components/schemas/ContractDetails"
},
"country_code": {
"type": "string",
"nullable": true,
"x-struct": null,
"x-validate": null
},
"country": {
"nullable": true,
"$ref": "#/components/schemas/Country"
},
"created_at": {
Expand All @@ -577,6 +578,7 @@
"$ref": "#/components/schemas/EmergencyContactDetails"
},
"files": {
"nullable": true,
"items": {
"$ref": "#/components/schemas/File"
},
Expand Down Expand Up @@ -645,19 +647,15 @@
"billing_address_details",
"company_id",
"contract_details",
"country",
"created_at",
"emergency_contact_details",
"files",
"full_name",
"id",
"type",
"job_title",
"onboarding_tasks",
"personal_details",
"personal_email",
"pricing_plan_details",
"status",
"updated_at"
],
"title": "Employment",
Expand Down Expand Up @@ -872,6 +870,7 @@
},
"country_code": {
"type": "string",
"nullable": true,
"x-struct": null,
"x-validate": null
},
Expand Down Expand Up @@ -1008,10 +1007,7 @@
"work_address_is_home_address": "yes",
"years_of_experience": "2"
},
"country": {
"code": "AUT",
"name": "Austria"
},
"country_code": "AUT",
"created_at": "2021-11-11T18:44:39",
"emergency_contact_details": {
"email": "taylor@johnson.com",
Expand Down
Loading

0 comments on commit 7a15f91

Please sign in to comment.