Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit b63b5ce

Browse files
committed
Remove fields marked as removed
I'm not sure why they're kept in the documentation
1 parent 703db1a commit b63b5ce

10 files changed

Lines changed: 158 additions & 729 deletions

File tree

transformer/src/parsers/doc/etc/annotation.rs

Lines changed: 97 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(super) struct Annotation {
1717
pub(super) deprecated: bool,
1818
pub(super) modifiable: Option<Modifiable>,
1919
pub(super) content_type: Option<String>,
20+
pub(super) removed: bool,
2021
}
2122

2223
#[derive(Error, Debug, PartialEq)]
@@ -33,6 +34,7 @@ impl Annotation {
3334
deprecated: self.deprecated || b.deprecated,
3435
modifiable: self.modifiable.or(b.modifiable),
3536
required: self.required.or(b.required),
37+
removed: self.removed || b.removed,
3638
}
3739
}
3840
}
@@ -95,14 +97,30 @@ impl TryFrom<&Vec<xmltree::XMLNode>> for Annotation {
9597
name,
9698
attributes,
9799
..
98-
}) if namespace == XML_SCHEMA_NS
99-
&& name == "documentation"
100-
&& attributes.get("source").map(String::as_str) == Some("deprecated") =>
101-
{
102-
true
100+
}) => {
101+
namespace == XML_SCHEMA_NS
102+
&& name == "documentation"
103+
&& attributes.get("source").map(String::as_str) == Some("deprecated")
104+
}
105+
_ => false,
106+
});
107+
let removed = children.iter().any(|child| match child {
108+
xmltree::XMLNode::Element(xmltree::Element {
109+
namespace: Some(namespace),
110+
name,
111+
attributes,
112+
..
113+
}) => {
114+
(namespace == XML_SCHEMA_NS
115+
&& name == "documentation"
116+
&& attributes.get("source").map(String::as_str) == Some("removed-in"))
117+
|| (namespace == "http://www.vmware.com/vcloud/meta"
118+
&& name == "version"
119+
&& attributes.contains_key("removed-in"))
103120
}
104121
_ => false,
105122
});
123+
106124
let modifiable = children
107125
.iter()
108126
.filter_map(|child| match child {
@@ -166,6 +184,7 @@ impl TryFrom<&Vec<xmltree::XMLNode>> for Annotation {
166184
deprecated,
167185
modifiable,
168186
content_type,
187+
removed,
169188
})
170189
}
171190
}
@@ -227,7 +246,8 @@ fn test_parse_annotation() {
227246
required: None,
228247
deprecated: false,
229248
modifiable: None,
230-
content_type: None
249+
content_type: None,
250+
removed: false
231251
})
232252
);
233253
}
@@ -251,7 +271,8 @@ fn test_parse_annotation_required() {
251271
required: Some(true),
252272
deprecated: false,
253273
modifiable: None,
254-
content_type: None
274+
content_type: None,
275+
removed: false
255276
})
256277
);
257278
}
@@ -277,7 +298,8 @@ fn test_parse_annotation_not_required() {
277298
required: Some(false),
278299
deprecated: false,
279300
modifiable: None,
280-
content_type: None
301+
content_type: None,
302+
removed: false
281303
})
282304
);
283305
}
@@ -300,7 +322,8 @@ fn test_parse_annotation_deprecated() {
300322
required: None,
301323
deprecated: true,
302324
modifiable: None,
303-
content_type: None
325+
content_type: None,
326+
removed: false
304327
})
305328
);
306329
}
@@ -325,7 +348,8 @@ fn test_parse_annotation_modifiable_create() {
325348
required: None,
326349
deprecated: false,
327350
modifiable: Some(Modifiable::Create),
328-
content_type: None
351+
content_type: None,
352+
removed: false
329353
})
330354
);
331355
}
@@ -348,7 +372,8 @@ fn test_parse_annotation_modifiable_update() {
348372
required: None,
349373
deprecated: false,
350374
modifiable: Some(Modifiable::Update),
351-
content_type: None
375+
content_type: None,
376+
removed: false
352377
})
353378
);
354379
}
@@ -371,7 +396,8 @@ fn test_parse_annotation_modifiable_always() {
371396
required: None,
372397
deprecated: false,
373398
modifiable: Some(Modifiable::Always),
374-
content_type: None
399+
content_type: None,
400+
removed: false
375401
})
376402
);
377403
}
@@ -394,7 +420,8 @@ fn test_parse_annotation_modifiable_none() {
394420
required: None,
395421
deprecated: false,
396422
modifiable: Some(Modifiable::None),
397-
content_type: None
423+
content_type: None,
424+
removed: false
398425
})
399426
);
400427
}
@@ -421,7 +448,8 @@ fn test_parse_content_type() {
421448
required: None,
422449
deprecated: false,
423450
modifiable: None,
424-
content_type: Some("application/vnd.ccouzens.test".to_owned())
451+
content_type: Some("application/vnd.ccouzens.test".to_owned()),
452+
removed: false
425453
})
426454
);
427455
}
@@ -447,7 +475,61 @@ fn test_parse_annotation_inside_app_info() {
447475
required: None,
448476
deprecated: false,
449477
modifiable: None,
450-
content_type: None
478+
content_type: None,
479+
removed: false
480+
})
481+
);
482+
}
483+
484+
#[test]
485+
fn test_annotation_indicating_removal() {
486+
let xml: &[u8] = br#"
487+
<xs:annotation xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:meta="http://www.vmware.com/vcloud/meta">
488+
<xs:appinfo><meta:version removed-in="API_VERSION_POST9_1_UPDATE"/></xs:appinfo>
489+
<xs:documentation source="modifiable">always</xs:documentation>
490+
<xs:documentation xml:lang="en">
491+
This field has been removed
492+
</xs:documentation>
493+
<xs:documentation source="required">false</xs:documentation>
494+
<xs:documentation source="deprecated">6.0</xs:documentation>
495+
<xs:documentation source="removed-in">API_VERSION_POST9_1_UPDATE</xs:documentation>
496+
</xs:annotation>"#;
497+
let tree = xmltree::Element::parse(xml).unwrap();
498+
assert_eq!(
499+
Annotation::try_from(&xmltree::XMLNode::Element(tree)),
500+
Ok(Annotation {
501+
description: Some("This field has been removed".to_owned()),
502+
required: Some(false),
503+
deprecated: true,
504+
modifiable: Some(Modifiable::Always),
505+
content_type: None,
506+
removed: true
507+
})
508+
);
509+
}
510+
511+
#[test]
512+
fn test_alternative_removal_syntax() {
513+
let xml: &[u8] = br#"
514+
<xs:annotation xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:meta="http://www.vmware.com/vcloud/meta">
515+
<xs:appinfo><meta:version removed-in="API_VERSION_POST9_1_UPDATE"/></xs:appinfo>
516+
<xs:documentation source="modifiable">always</xs:documentation>
517+
<xs:documentation xml:lang="en">
518+
This field has been removed
519+
</xs:documentation>
520+
<xs:documentation source="required">false</xs:documentation>
521+
<xs:documentation source="deprecated">6.0</xs:documentation>
522+
</xs:annotation>"#;
523+
let tree = xmltree::Element::parse(xml).unwrap();
524+
assert_eq!(
525+
Annotation::try_from(&xmltree::XMLNode::Element(tree)),
526+
Ok(Annotation {
527+
description: Some("This field has been removed".to_owned()),
528+
required: Some(false),
529+
deprecated: true,
530+
modifiable: Some(Modifiable::Always),
531+
content_type: None,
532+
removed: true
451533
})
452534
);
453535
}

transformer/src/parsers/doc/etc/field.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub enum FieldParseError {
3232
MissingType,
3333
#[error("not a sequence element node")]
3434
NotFieldNode,
35+
#[error("this field is marked as removed")]
36+
Removed,
3537
}
3638

3739
impl TryFrom<(&xmltree::XMLNode, &str)> for Field {
@@ -83,6 +85,9 @@ impl TryFrom<(&xmltree::XMLNode, &str)> for Field {
8385
_ => Occurrences::One,
8486
};
8587
let annotation = children.iter().flat_map(Annotation::try_from).next();
88+
if annotation.as_ref().map(|a| a.removed) == Some(true) {
89+
return Err(FieldParseError::Removed);
90+
}
8691
Ok(Field {
8792
annotation,
8893
name,

transformer/src/parsers/doc/etc/object_type.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ impl TryFrom<(&xmltree::XMLNode, &str)> for ObjectType {
151151
description: None,
152152
modifiable: None,
153153
required: Some(true),
154+
removed: false,
154155
}),
155156
name: "value".into(),
156157
occurrences: Occurrences::One,
@@ -425,3 +426,58 @@ fn parse_annotation_inside_complex_content_test() {
425426
})
426427
);
427428
}
429+
430+
#[test]
431+
fn removed_field_test() {
432+
let xml: &[u8] = br#"
433+
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:meta="http://www.vmware.com/vcloud/meta" abstract="true" name="BaseType">
434+
<xs:annotation>
435+
<xs:documentation source="since">0.9</xs:documentation>
436+
<xs:documentation xml:lang="en">
437+
A base abstract type for all the types.
438+
</xs:documentation>
439+
</xs:annotation>
440+
441+
<xs:sequence>
442+
<xs:element name="FieldA" type="xs:string" minOccurs="0">
443+
<xs:annotation>
444+
<xs:appinfo><meta:version added-in="1.0" removed-in="5.1"/></xs:appinfo>
445+
<xs:documentation source="modifiable">always</xs:documentation>
446+
<xs:documentation xml:lang="en">
447+
A field that has been removed
448+
</xs:documentation>
449+
<xs:documentation source="required">false</xs:documentation>
450+
</xs:annotation>
451+
</xs:element>
452+
<xs:element name="FieldB" type="xs:string" minOccurs="0">
453+
<xs:annotation>
454+
<xs:documentation source="modifiable">always</xs:documentation>
455+
<xs:documentation xml:lang="en">
456+
A field that has not been removed
457+
</xs:documentation>
458+
<xs:documentation source="required">false</xs:documentation>
459+
</xs:annotation>
460+
</xs:element>
461+
462+
</xs:sequence>
463+
</xs:complexType>
464+
"#;
465+
let tree = xmltree::Element::parse(xml).unwrap();
466+
let c = Type::try_from((&xmltree::XMLNode::Element(tree), "test")).unwrap();
467+
let value = openapiv3::Schema::from(&c);
468+
assert_eq!(
469+
serde_json::to_value(value).unwrap(),
470+
json!({
471+
"title": "test_BaseType",
472+
"description": "A base abstract type for all the types.",
473+
"type": "object",
474+
"properties": {
475+
"fieldB": {
476+
"description": "A field that has not been removed",
477+
"type": "string"
478+
}
479+
},
480+
"additionalProperties": false
481+
})
482+
);
483+
}

website/27.0.json

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19972,15 +19972,6 @@
1997219972
}
1997319973
]
1997419974
},
19975-
"storageCapacity": {
19976-
"readOnly": true,
19977-
"description": "Read\\-only indicator of datastore capacity.",
19978-
"allOf": [
19979-
{
19980-
"$ref": "#/components/schemas/vcloud_ProviderVdcCapacityType"
19981-
}
19982-
]
19983-
},
1998419975
"availableNetworks": {
1998519976
"readOnly": true,
1998619977
"description": "Read\\-only list of available networks.",
@@ -28872,9 +28863,6 @@
2887228863
"description": "An arbitrary key name. Length cannot exceed 256 UTF\\-8 characters.",
2887328864
"type": "string"
2887428865
},
28875-
"value": {
28876-
"type": "string"
28877-
},
2887828866
"typedValue": {
2887928867
"description": "One of: \n MetadataStringValue \n MetadataNumberValue \n MetadataBooleanValue \n MetadataDateTimeValue",
2888028868
"allOf": [
@@ -29024,9 +29012,6 @@
2902429012
}
2902529013
]
2902629014
},
29027-
"value": {
29028-
"type": "string"
29029-
},
2903029015
"typedValue": {
2903129016
"allOf": [
2903229017
{
@@ -31743,15 +31728,6 @@
3174331728
"description": "Compatibility mode. Default is false. If set to true, will allow users to write firewall rules in the old 1.5 format. The new format does not require to use direction in firewall rules. Also, for firewall rules to allow NAT traffic the filter is applied on the original IP addresses. Once set to true cannot be reverted back to false.",
3174431729
"type": "boolean"
3174531730
},
31746-
"ipScope": {
31747-
"deprecated": true,
31748-
"description": "Includes IP level configuration items such as gateway, dns, subnet, IP address pool to be used for allocation. Note that the pool of IP addresses needs to fall within the subnet/mask of the IpScope.",
31749-
"allOf": [
31750-
{
31751-
"$ref": "#/components/schemas/vcloud_IpScopeType"
31752-
}
31753-
]
31754-
},
3175531731
"ipScopes": {
3175631732
"description": "A list of IP scopes for the network.",
3175731733
"allOf": [
@@ -40328,14 +40304,6 @@
4032840304
"description": "The allocation model used by this vDC. One of: \n**AllocationVApp** (Pay as you go. Resources are committed to a vDC only when vApps are created in it. When you use this allocation model, any Limit values you specify for Memory and CPU are ignored on create and returned as 0 on retrieve.) \n**AllocationPool** (Only a percentage of the resources you allocate are committed to the organization vDC.) \n**ReservationPool** (All the resources you allocate are committed as a pool to the organization vDC. vApps in vDCs that support this allocation model can specify values for resource and limit.)",
4032940305
"type": "string"
4033040306
},
40331-
"storageCapacity": {
40332-
"description": "The storage capacity allocated to this vDC.",
40333-
"allOf": [
40334-
{
40335-
"$ref": "#/components/schemas/vcloud_CapacityWithUsageType"
40336-
}
40337-
]
40338-
},
4033940307
"computeCapacity": {
4034040308
"description": "The compute capacity allocated to this vDC.",
4034140309
"allOf": [

0 commit comments

Comments
 (0)