Skip to content

Commit 4d3ff2e

Browse files
authored
Allow readOnly attribute in TypedProperty OpenAPI spec (#134) (#144)
Fixes: rdar://91505904
1 parent 6bd369d commit 4d3ff2e

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

Sources/SwiftDocC/Model/Rendering/Symbol/PropertiesRenderSection.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public struct RenderProperty: Codable, TextIndexing, Equatable {
6969
public var required: Bool? = false
7070
/// If true, the property is deprecated.
7171
public var deprecated: Bool? = false
72+
/// If true, the property can only be accessed and not modified.
73+
public var readOnly: Bool? = false
7274
/// A version of the platform that first introduced the property, if known.
7375
public var introducedVersion: String?
7476
}

Sources/SwiftDocC/SwiftDocC.docc/Resources/RenderNode.spec.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,6 +2800,9 @@
28002800
"mimeType": {
28012801
"type": "string"
28022802
},
2803+
"readOnly": {
2804+
"type": "boolean"
2805+
},
28032806
"required": {
28042807
"type": "boolean"
28052808
},

Tests/SwiftDocCTests/Rendering/RESTSymbolsTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,13 @@ class RESTSymbolsTests: XCTestCase {
244244
XCTAssertEqual(properties.items.count, 2)
245245
guard properties.items.count == 2 else { return }
246246

247-
// The first property is not deprecated but required
247+
// The first property is not deprecated/readonly but required
248248
XCTAssertNil(properties.items[0].deprecated)
249+
XCTAssertNil(properties.items[0].readOnly)
249250
XCTAssertEqual(properties.items[0].required, true)
250-
// The second property is deprecated but not required
251+
// The second property is deprecated/readonly but not required
251252
XCTAssertEqual(properties.items[1].deprecated, true)
253+
XCTAssertEqual(properties.items[1].readOnly, true)
252254
XCTAssertNil(properties.items[1].required)
253255

254256
guard let attributes = properties.items[0].attributes else {

Tests/SwiftDocCTests/Rendering/Rendering Fixtures/rest-object.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
{
137137
"name" : "status",
138138
"deprecated" : true,
139+
"readOnly" : true,
139140
"type" : [
140141
{
141142
"kind" : "identifier",

0 commit comments

Comments
 (0)