Skip to content

RenderIndex.spec.json has required property that isn't defined in OpenAPI spec #1223

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

Open
2 tasks done
heckj opened this issue May 18, 2025 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@heckj
Copy link
Member

heckj commented May 18, 2025

Description

The RenderIndex OpenAPI spec has a required field for RenderIndex that isn't defined in the schema: schemaVersion

"RenderIndex": {
                "type": "object",
                "required": [
                    "schemaVersion",
                    "interfaceLanguages"
                ],
                "properties": {
                    "identifier": {
                        "$ref": "#/components/schemas/SchemaVersion"
                    },
                    "interfaceLanguages": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "$ref": "#/components/schemas/Node"
                            }
                        }
                    },
...

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

No response

Actual behavior

No response

Steps To Reproduce

git clone https://github.com/apple/swift-openapi-generator
cd swift-openapi-generator
swift run swift-openapi-generator generate --mode types --output-directory . ~/src/swift-project/swift-docc/Sources/SwiftDocC/SwiftDocC.docc/Resources/RenderIndex.spec.json --dry-run

Warning generated:

warning: A property name only appears in the required list, but not in the properties map - this is likely a typo; skipping this property. [context: foundIn=Components.Schemas.RenderIndex (#/components/schemas/RenderIndex)/schemaVersion]

Swift-DocC Version Information

f47942a

Swift Compiler Version Information

Apple Swift version 6.1 (swift-6.1-RELEASE)
Target: arm64-apple-macosx15.0
@heckj heckj added the bug Something isn't working label May 18, 2025
@heckj
Copy link
Member Author

heckj commented May 18, 2025

Should identifier be in the required fields instead of schemaVersion, since it has that type?

@heckj
Copy link
Member Author

heckj commented May 19, 2025

I didn't spot anything that provide verification that the schema provided actually matches renderer output - or that it was able to be validated by OpenAPI. While I believe I have the correct answer in the fix, what's the best way to provide tests for this?

The path that immediately comes to mind would be to render a sample docc catalog of some form (I used SlothCreator in my exploration of the issue), and then use generated code from the provided OpenAPI spec to read and validate the schema based on the provided content in /Sources/SwiftDocC/SwiftDocC.docc/Resources/*

I'd be tempted to lean into use swift-openapi-generator as a dependency in such a test - would that be acceptable? Or is there another path at testing that would be preferred?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant