-
Notifications
You must be signed in to change notification settings - Fork 146
corrects schema version property name in RenderIndex.spec.json #1224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
heckj
wants to merge
3
commits into
swiftlang:main
Choose a base branch
from
heckj:renderindex-spec-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Tests/SwiftDocCTests/ArchiveModelSpecs/ArchiveModelSpecValidationTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Foundation | ||
import XCTest | ||
import _OpenAPIGeneratorCore | ||
import OpenAPIKit | ||
@testable import SwiftDocC | ||
|
||
class ArchiveModelSpecValidationTests: XCTestCase { | ||
|
||
struct ThrowingDiagnosticCollector: DiagnosticCollector, Sendable { | ||
public init() {} | ||
public func emit(_ diagnostic: _OpenAPIGeneratorCore.Diagnostic) throws { | ||
if diagnostic.severity == .warning || diagnostic.severity == .error { | ||
throw diagnostic | ||
} | ||
} | ||
} | ||
|
||
func testOpenAPISpecIsValid() throws { | ||
let renderIndexspecURL = Bundle.module.url( | ||
forResource: "RenderIndex.spec", withExtension: "json", subdirectory: "Test Resources")! | ||
let data = try Data(contentsOf: renderIndexspecURL) | ||
|
||
let diagCollector = ThrowingDiagnosticCollector() | ||
|
||
let _ = try _OpenAPIGeneratorCore.runGenerator(input: .init(absolutePath: renderIndexspecURL, contents: data), config: Config( | ||
mode: .types, | ||
access: Config.defaultAccessModifier, | ||
namingStrategy: Config.defaultNamingStrategy | ||
), diagnostics: diagCollector) | ||
} | ||
} |
199 changes: 199 additions & 0 deletions
199
Tests/SwiftDocCTests/Test Resources/RenderIndex.spec.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"description": "Specification of the Swift-DocC Index.json file.", | ||
"version": "0.1.2", | ||
"title": "RenderIndex" | ||
}, | ||
"paths": {}, | ||
"components": { | ||
"schemas": { | ||
"RenderIndex": { | ||
"type": "object", | ||
"required": [ | ||
"identifier", | ||
"interfaceLanguages", | ||
], | ||
"properties": { | ||
"schemaVersion": { | ||
"$ref": "#/components/schemas/SchemaVersion" | ||
}, | ||
"interfaceLanguages": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Node" | ||
} | ||
} | ||
}, | ||
"references": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"$ref": "#/components/schemas/ImageRenderReference" | ||
} | ||
}, | ||
"includedArchiveIdentifiers": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"Node": { | ||
"type": "object", | ||
"required": [ | ||
"title" | ||
], | ||
"properties": { | ||
"title": { | ||
"type": "string" | ||
}, | ||
"type": { | ||
"type": "string", | ||
"enum": [ | ||
"article", | ||
"associatedtype", | ||
"buildSetting", | ||
"case", | ||
"collection", | ||
"class", | ||
"container", | ||
"dictionarySymbol", | ||
"enum", | ||
"extension", | ||
"func", | ||
"groupMarker", | ||
"httpRequest", | ||
"init", | ||
"languageGroup", | ||
"learn", | ||
"macro", | ||
"method", | ||
"module", | ||
"op", | ||
"overview", | ||
"project", | ||
"property", | ||
"propertyListKey", | ||
"propertyListKeyReference", | ||
"protocol", | ||
"resources", | ||
"root", | ||
"sampleCode", | ||
"section", | ||
"struct", | ||
"subscript", | ||
"symbol", | ||
"typealias", | ||
"union", | ||
"var" | ||
] | ||
}, | ||
"path": { | ||
"type": "string" | ||
}, | ||
"deprecated": { | ||
"type": "boolean", | ||
"default": "false" | ||
}, | ||
"external": { | ||
"type": "boolean", | ||
"default": "false" | ||
}, | ||
"beta": { | ||
"type": "boolean", | ||
"default": "false" | ||
}, | ||
"icon": { | ||
"type": "string", | ||
"format": "reference(ImageRenderReference)" | ||
}, | ||
"children": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Node" | ||
} | ||
} | ||
} | ||
}, | ||
"SchemaVersion": { | ||
"type": "object", | ||
"required": [ | ||
"major", | ||
"minor", | ||
"patch" | ||
], | ||
"properties": { | ||
"major": { | ||
"type": "integer" | ||
}, | ||
"minor": { | ||
"type": "integer" | ||
}, | ||
"patch": { | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"ImageRenderReference": { | ||
"type": "object", | ||
"required": [ | ||
"type", | ||
"identifier", | ||
"variants" | ||
], | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"enum": ["image"] | ||
}, | ||
"alt": { | ||
"type": "string", | ||
"nullable": true | ||
}, | ||
"identifier": { | ||
"type": "string" | ||
}, | ||
"variants": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/RenderReferenceVariant" | ||
} | ||
} | ||
} | ||
}, | ||
"RenderReferenceVariant": { | ||
"type": "object", | ||
"required": [ | ||
"url", | ||
"traits" | ||
], | ||
"properties": { | ||
"url": { | ||
"type": "string" | ||
}, | ||
"svgID": { | ||
"type": "string", | ||
"description": "The ID attribute for the image that should be rendered in the SVG file represented by this variant." | ||
}, | ||
"traits": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/RenderReferenceVariantTrait" | ||
} | ||
} | ||
} | ||
}, | ||
"RenderReferenceVariantTrait": { | ||
"type": "string", | ||
"enum": ["1x", "2x", "3x", "light", "dark"] | ||
} | ||
}, | ||
"requestBodies": {}, | ||
"securitySchemes": {}, | ||
"links": {}, | ||
"callbacks": {} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: If we add this dependency, it—and all its transient dependencies—will be used when building DocC for toolchains builds. This significantly increases the amount of work necessary to merge this PR because we need to check if anything else in the toolchain depend on any version of these dependencies and ensure that those versions are compatible, now and in the future. If we can skip this dependency it would make it easier to merge this PR. Otherwise someone will write access to various Swift repositories will need to spend some time making toolchain builds to verify that these new dependencies don't break the toolchain builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was afraid of that.
Since the project chose to provide OpenAPI schema files as a description, what would be the best way to verify them? The dependency isn't the only problem - going from them as resources to something you can write a test to verify is another awkward part here.
I wanted to explore what might be possible in testing, and this PR reflects a baseline of it, but it adds a huge amount of overhead, as you're mentioning.