diff --git a/CODEOWNERS b/.github/CODEOWNERS similarity index 81% rename from CODEOWNERS rename to .github/CODEOWNERS index 9a79490..5d6c72c 100644 --- a/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,11 +3,10 @@ # Workflow & Deployment related files .github/* @ffried -.jazzy.yaml @ffried .codecov.yml @ffried # Project & Source files *.swift @ffried -/Package.* @ffried +/Package*.swift @ffried /Sources/* @ffried /Tests/* @ffried diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0b244e4..1cdf9b2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,13 +1,24 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / open-pull-requests-limit: 10 schedule: - interval: "daily" - time: "07:00" - timezone: "Europe/Berlin" + interval: daily + time: 07:00 + timezone: Europe/Berlin + assignees: + - ffried + reviewers: + - ffried + - package-ecosystem: swift + directory: / + open-pull-requests-limit: 10 + schedule: + interval: daily + time: 07:00 + timezone: Europe/Berlin assignees: - ffried reviewers: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a17e022..0b5e5e7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,229 +8,19 @@ on: push: branches: [ main ] -jobs: - release-context: - runs-on: ubuntu-latest - outputs: - version-name: ${{ github.ref_name }} - is-latest: ${{ steps.compare-tags.outputs.is-latest }} - steps: - - uses: joutvhu/get-release@v1 - id: latest-release - with: - latest: true - throwing: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Compare tags - id: compare-tags - env: - REF_TYPE: ${{ github.ref_type }} - REF_NAME: ${{ github.ref_name }} - LATEST_TAG: ${{ steps.latest-release.outputs.tag_name }} - run: | - if [ "${REF_TYPE}" == 'tag' ] && [ "${REF_NAME}" == "${LATEST_TAG}" ]; then - echo 'is-latest=true' >> "${GITHUB_OUTPUT}" - else - echo 'is-latest=false' >> "${GITHUB_OUTPUT}" - fi - - spm-context: - runs-on: ubuntu-latest - outputs: - package-dump: ${{ steps.dump-package.outputs.package-dump }} - steps: - - uses: swift-actions/setup-swift@v1.24.0 - with: - swift-version: '5.8' - - uses: actions/checkout@v4 - # We don't use a cache here, because SPM doesn't resolve dependencies when dumping packages. - - name: Dump package - id: dump-package - run: | - delimiter="$(openssl rand -hex 8)" - echo "package-dump<<${delimiter}" >> "${GITHUB_OUTPUT}" - swift package dump-package >> "${GITHUB_OUTPUT}" - echo "${delimiter}" >> "${GITHUB_OUTPUT}" +permissions: + contents: write - generate-docs: - needs: - - release-context - - spm-context - runs-on: ubuntu-latest - strategy: - matrix: - target: ${{ fromJson(needs.spm-context.outputs.package-dump).products.*.targets.* }} - steps: - - uses: swift-actions/setup-swift@v1.24.0 - id: swift-setup - with: - swift-version: '5.8' - - name: Read OS Version - uses: sersoft-gmbh/os-version-action@v3 - id: os-version - - uses: actions/checkout@v4 - - uses: actions/cache@v3 - with: - path: .build - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-setup.outputs.version }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-setup.outputs.version }}- - - uses: sersoft-gmbh/swifty-docs-action@v3 - env: - ENABLE_DOCC_SUPPORT: '1' - DOCC_JSON_PRETTYPRINT: 'YES' - with: - package-version: ${{ needs.release-context.outputs.version-name }} - targets: ${{ matrix.target }} - enable-inherited-docs: true - enable-index-building: false - transform-for-static-hosting: true - hosting-base-path: ${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }} - output: ${{ matrix.target }}-docs - - name: Package docs - env: - TARGET: ${{ matrix.target }} - run: tar -cvf "${TARGET}-docs.tar" "${TARGET}-docs" - - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }}-docs - path: ${{ matrix.target }}-docs.tar +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true - publish-docs: - needs: - - release-context - - spm-context - - generate-docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: gh-pages - path: repository - - uses: actions/download-artifact@v3 - with: - path: artifacts - - name: Extract tars - run: find artifacts -name '*.tar' -execdir tar -xvf '{}' --strip-components 1 \; -delete - - name: Merge documentations - env: - TARGETS: ${{ join(fromJson(needs.spm-context.outputs.package-dump).products.*.targets.*, ' ') }} - DOCS_BASE_DIR: repository/${{ needs.release-context.outputs.version-name }} - run: | - rm -rf "${DOCS_BASE_DIR}" - is_first=1 - for target in $TARGETS; do - if [ $is_first -eq 1 ]; then - echo "Copying initial documentation for ${target}" - cp -R "artifacts/${target}-docs" "${DOCS_BASE_DIR}" - is_first=0 - else - echo "Merging documentation for ${target}" - cp -R "artifacts/${target}-docs/data/documentation/"* "${DOCS_BASE_DIR}/data/documentation/" - cp -R "artifacts/${target}-docs/documentation/"* "${DOCS_BASE_DIR}/documentation/" - fi - done - echo "Deleting non-mergable metadata.json" - rm -f "${DOCS_BASE_DIR}/metadata.json" - - name: Create version index - working-directory: repository - env: - TARGET_DOCS_DIR: ${{ needs.release-context.outputs.version-name }}/documentation - INDEX_FILE: ${{ needs.release-context.outputs.version-name }}/index.html - BASE_URL: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }}/documentation' - REPO_NAME: ${{ github.event.repository.name }} - run: | - target_count=0 - target_list="" - single_target_name="" - for target in $(ls "${TARGET_DOCS_DIR}"); do - if [ -d "${TARGET_DOCS_DIR}/${target}" ]; then - single_target_name="${target}" - target_count=$((target_count+1)) - target_list="${target_list}
  • ${target} Documentation
  • " - fi - done - if [ ${target_count} -gt 1 ]; then - echo "Found ${target_count} targets. Generating list..." - cat > "${INDEX_FILE}" < - - - ${REPO_NAME} Documentation - - - - - - EOF - else - echo "Found one target. Generating redirect file to target ${single_target_name}" - cat > "${INDEX_FILE}" < - - - ${REPO_NAME} Documentation - - - -

    Redirecting...

    - - - EOF - fi - - name: Create root index - working-directory: repository - env: - REDIRECT_URL: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/latest' - REPO_NAME: ${{ github.event.repository.name }} - run: | - cat > 'index.html' < - - - ${REPO_NAME} Documentation - - - -

    Redirecting...

    - - - EOF - - name: Create latest symlink - if: ${{ needs.release-context.outputs.is-latest }} - working-directory: repository - env: - VERSION_NAME: ${{ needs.release-context.outputs.version-name }} - run: | - rm -f 'latest' - ln -s "${VERSION_NAME}" 'latest' - - name: Determine changes - id: check-changes - working-directory: repository - run: | - if [ -n "$(git status --porcelain)" ]; then - echo 'has-changes=true' >> "${GITHUB_OUTPUT}" - else - echo 'has-changes=false' >> "${GITHUB_OUTPUT}" - fi - - uses: crazy-max/ghaction-github-pages@v4 - if: ${{ steps.check-changes.outputs.has-changes }} - with: - keep_history: true - build_dir: repository - commit_message: Deploy documentation for '${{ needs.release-context.outputs.version-name }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cleanup: - needs: - - generate-docs - - publish-docs - if: ${{ always() }} - runs-on: ubuntu-latest - steps: - - name: Cleanup Artifacts - uses: joutvhu/delete-artifact@v1 +jobs: + generate-and-publish-docs: + uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-generate-and-publish-docs.yml@main + with: + os: ubuntu + swift-version: '5.9' + organisation: ${{ github.repository_owner }} + repository: ${{ github.event.repository.name }} + pages-branch: gh-pages diff --git a/.github/workflows/enable-auto-merge.yml b/.github/workflows/enable-auto-merge.yml index 6b3a13a..74fbf98 100644 --- a/.github/workflows/enable-auto-merge.yml +++ b/.github/workflows/enable-auto-merge.yml @@ -1,6 +1,8 @@ name: Auto-merge for Dependabot PRs -on: pull_request +on: + pull_request: + branches: [ main ] permissions: contents: write diff --git a/.github/workflows/swift-test.yml b/.github/workflows/swift-test.yml index 30ecaae..ff8f66f 100644 --- a/.github/workflows/swift-test.yml +++ b/.github/workflows/swift-test.yml @@ -6,135 +6,53 @@ on: pull_request: branches: [ main ] +permissions: + contents: read + jobs: + variables: + outputs: + max-supported-swift-version: '5.9' + xcode-scheme: route-docs + xcode-platform-version: latest + fail-if-codecov-fails: true + runs-on: ubuntu-latest + steps: + - run: exit 0 + test-spm: + needs: variables strategy: matrix: - os: [ macos-13 ] - swift-version: [ '' ] - xcode-version: [ '^14.3' ] - include: - - os: ubuntu-20.04 - swift-version: 5.8 - xcode-version: '' - - os: ubuntu-22.04 - swift-version: 5.8 - xcode-version: '' - - runs-on: ${{ matrix.os }} - - steps: - - if: ${{ runner.os == 'macOS' }} - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{ matrix.xcode-version }} - - name: Install Swift - if: ${{ runner.os == 'Linux' }} - uses: sersoft-gmbh/swifty-linux-action@v3 - with: - release-version: ${{ matrix.swift-version }} - platform: ${{ matrix.os }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Read OS Version - uses: sersoft-gmbh/os-version-action@v3 - id: os-version - - name: Read Swift Version - uses: sersoft-gmbh/swift-version-action@v3 - id: swift-version - - uses: actions/checkout@v4 - - uses: actions/cache@v3 - with: - path: .build - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}- - - name: Build & Test - run: swift test -v --parallel --enable-code-coverage - - name: Generate Coverage Files - uses: sersoft-gmbh/swift-coverage-action@v4 - id: coverage-files - - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} - fail_ci_if_error: true + os: [ macOS, ubuntu ] + swift-version-offset: [ 0 ] + uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-spm.yml@main + with: + os: ${{ matrix.os }} + max-swift-version: ${{ needs.variables.outputs.max-supported-swift-version }} + swift-version-offset: ${{ matrix.swift-version-offset }} + fail-if-codecov-fails: ${{ fromJson(needs.variables.outputs.fail-if-codecov-fails) }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} test-xcode: - runs-on: macos-13 + needs: variables strategy: matrix: platform: - macOS - env: - XCODE_SCHEME: route-docs - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ^14.3 - - name: Read OS Version - uses: sersoft-gmbh/os-version-action@v3 - id: os-version - - name: Read Swift Version - uses: sersoft-gmbh/swift-version-action@v3 - id: swift-version - - name: Select destination - id: destination - env: - PLATFORM: ${{ matrix.platform }} - run: | - DESTINATION='' - case "${PLATFORM}" in - 'macOS') DESTINATION='platform=macOS';; - 'iOS') DESTINATION='platform=iOS Simulator,OS=latest,name=iPhone 13 Pro';; - 'iPadOS') DESTINATION='platform=iOS Simulator,OS=latest,name=iPad Pro (11-inch) (3rd generation)';; - 'tvOS') DESTINATION='platform=tvOS Simulator,OS=latest,name=Apple TV 4K (2nd generation)';; - 'watchOS') DESTINATION='platform=watchOS Simulator,OS=latest,name=Apple Watch Series 7 (45mm)';; - *) echo "::error title=Unknown platform!::Unknown platform: ${PLATFORM}" && exit 1;; - esac - echo "xcode=${DESTINATION}" >> "${GITHUB_OUTPUT}" - - uses: actions/checkout@v4 - # PIF ISSUES: https://github.com/apple/swift-package-manager/issues/5767 - - uses: actions/cache@v3 - with: - path: .build - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}- - - name: Work around PIF issues - env: - DESTINATION: ${{ steps.destination.outputs.xcode }} - run: | - swift package dump-pif > /dev/null - ATTEMPT=0 - while [ -z "${SUCCESS}" ] && [ "${ATTEMPT}" -le 5 ]; do - xcodebuild clean -scheme "${XCODE_SCHEME}" -destination "${DESTINATION}" | grep -q "CLEAN SUCCEEDED" && SUCCESS=true - ATTEMPT=$((ATTEMPT + 1)) - done - # END PIF ISSUES - - uses: actions/cache@v3 - with: - path: .derived-data - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-xcode-${{ steps.swift-version.outputs.version }}-${{ matrix.platform }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-xcode-${{ steps.swift-version.outputs.version }}-${{ matrix.platform }}- - - uses: sersoft-gmbh/xcodebuild-action@v3 - with: - spm-package: './' - scheme: ${{ env.XCODE_SCHEME }} - destination: ${{ steps.destination.outputs.xcode }} - action: test - parallel-testing-enabled: ${{ matrix.platform != 'watchOS' }} - enable-code-coverage: true - derived-data-path: .derived-data - - uses: sersoft-gmbh/swift-coverage-action@v4 - id: coverage-files - with: - search-paths: | - ./.build - ./.derived-data - $HOME/Library/Developer/Xcode/DerivedData - - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} - fail_ci_if_error: true + # - iOS + # - iPadOS + # - tvOS + # - watchOS + swift-version-offset: [ 0 ] + uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-xcode.yml@main + with: + xcode-scheme: ${{ needs.variables.outputs.xcode-scheme }} + max-swift-version: ${{ needs.variables.outputs.max-supported-swift-version }} + swift-version-offset: ${{ matrix.swift-version-offset }} + platform: ${{ matrix.platform }} + platform-version: ${{ needs.variables.outputs.xcode-platform-version }} + fail-if-codecov-fails: ${{ fromJson(needs.variables.outputs.fail-if-codecov-fails) }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index dec7957..13bc1d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,23 @@ .DS_Store + /.build -/.swiftpm /Packages -/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc + +# VS Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix diff --git a/Package.resolved b/Package.resolved index a5bfc92..6b224fe 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swift-server/async-http-client.git", "state" : { - "revision" : "78db67e5bf4a8543075787f228e8920097319281", - "version" : "1.18.0" + "revision" : "16f7e62c08c6969899ce6cc277041e868364e5cf", + "version" : "1.19.0" } }, { @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/console-kit.git", "state" : { - "revision" : "447f1046fb4e9df40973fe426ecb24a6f0e8d3b4", - "version" : "4.6.0" + "revision" : "d4b580e466c61f82a46d6bcc0b356add388f7ad2", + "version" : "4.8.1" } }, { @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/routing-kit.git", "state" : { - "revision" : "611bc45c5dfb1f54b84d99b89d1f72191fb6b71b", - "version" : "4.7.2" + "revision" : "e0539da5b60a60d7381f44cdcf04036f456cee2f", + "version" : "4.8.0" } }, { @@ -81,15 +81,6 @@ "version" : "1.1.0" } }, - { - "identity" : "swift-backtrace", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/swift-backtrace.git", - "state" : { - "revision" : "f25620d5d05e2f1ba27154b40cafea2b67566956", - "version" : "1.3.3" - } - }, { "identity" : "swift-collections", "kind" : "remoteSourceControl", @@ -104,8 +95,26 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-crypto.git", "state" : { - "revision" : "60f13f60c4d093691934dc6cfdf5f508ada1f894", - "version" : "2.6.0" + "revision" : "629f0b679d0fd0a6ae823d7f750b9ab032c00b80", + "version" : "3.0.0" + } + }, + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-plugin", + "state" : { + "revision" : "26ac5758409154cc448d7ab82389c520fa8a8247", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" } }, { @@ -129,10 +138,10 @@ { "identity" : "swift-nio", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", + "location" : "https://github.com/apple/swift-nio", "state" : { - "revision" : "cf281631ff10ec6111f2761052aa81896a83a007", - "version" : "2.58.0" + "revision" : "3db5c4aeee8100d2db6f1eaf3864afdad5dc68fd", + "version" : "2.59.0" } }, { @@ -140,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997", - "version" : "1.19.0" + "revision" : "fb70a0f5e984f23be48b11b4f1909f3bee016178", + "version" : "1.19.1" } }, { @@ -158,8 +167,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-ssl.git", "state" : { - "revision" : "e866a626e105042a6a72a870c88b4c531ba05f83", - "version" : "2.24.0" + "revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9", + "version" : "2.25.0" } }, { @@ -183,10 +192,10 @@ { "identity" : "vapor", "kind" : "remoteSourceControl", - "location" : "https://github.com/vapor/vapor.git", + "location" : "https://github.com/vapor/vapor", "state" : { - "revision" : "474d91b67db9515b5bf3f3558635955c3fe18a44", - "version" : "4.78.1" + "revision" : "036d67e4da46126810f56c6a6ce813bcf259a745", + "version" : "4.84.1" } }, { diff --git a/Package.swift b/Package.swift index d70a43a..78d5865 100644 --- a/Package.swift +++ b/Package.swift @@ -1,8 +1,17 @@ -// swift-tools-version:5.8 +// swift-tools-version:5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription -import Foundation + +let swiftSettings: Array = [ + .enableUpcomingFeature("ConciseMagicFile"), + .enableUpcomingFeature("ExistentialAny"), + .enableUpcomingFeature("BareSlashRegexLiterals"), + .enableUpcomingFeature("DisableOutwardActorInference"), +// .enableExperimentalFeature("AccessLevelOnImport"), +// .enableExperimentalFeature("VariadicGenerics"), +// .unsafeFlags(["-warn-concurrency"], .when(configuration: .debug)), +] let package = Package( name: "route-docs", @@ -17,10 +26,11 @@ let package = Package( ], dependencies: [ // Dependencies declare other packages that this package depends on. - .package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.50.0"), - .package(url: "https://github.com/vapor/leaf-kit.git", from: "1.3.0"), - .package(url: "https://github.com/vapor/leaf.git", from: "4.0.0"), + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + .package(url: "https://github.com/apple/swift-nio", from: "2.59.0"), + .package(url: "https://github.com/vapor/vapor", from: "4.84.0"), + .package(url: "https://github.com/vapor/leaf-kit", from: "1.10.0"), + .package(url: "https://github.com/vapor/leaf", from: "4.2.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. @@ -35,13 +45,11 @@ let package = Package( ], resources: [ .copy("DefaultDocsView"), - ]), + ], + swiftSettings: swiftSettings), .testTarget( name: "RouteDocsTests", - dependencies: ["RouteDocs"]), + dependencies: ["RouteDocs"], + swiftSettings: swiftSettings), ] ) - -if ProcessInfo.processInfo.environment["ENABLE_DOCC_SUPPORT"] == "1" { - package.dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")) -} diff --git a/Sources/RouteDocs/DocsViewContext.swift b/Sources/RouteDocs/DocsViewContext.swift index 9868084..e2c0309 100644 --- a/Sources/RouteDocs/DocsViewContext.swift +++ b/Sources/RouteDocs/DocsViewContext.swift @@ -1,21 +1,21 @@ import Vapor /// This can be used as context for a documentation view. -public struct DocsViewContext: Encodable, Sendable { - public struct Documentation: Encodable, Sendable { - public struct Object: Encodable, Sendable { - public enum Body: Encodable, Sendable { +public struct DocsViewContext: Sendable, Encodable { + public struct Documentation: Sendable, Encodable { + public struct Object: Sendable, Encodable { + public enum Body: Sendable, Encodable { private enum CodingKeys: String, CodingKey { case isEmpty, fields, cases } - public struct Field: Encodable, Sendable { + public struct Field: Sendable, Encodable { public let name: String public let type: String public let isOptional: Bool } - public struct EnumCase: Encodable, Sendable { + public struct EnumCase: Sendable, Encodable { public let name: String? public let value: String } @@ -42,11 +42,12 @@ public struct DocsViewContext: Encodable, Sendable { } } } + public let name: String public let body: Body } - public struct Query: Encodable, Sendable { + public struct Query: Sendable, Encodable { public let objects: Array } @@ -63,7 +64,7 @@ public struct DocsViewContext: Encodable, Sendable { public let requiredAuthorization: Array } - public struct GroupedDocumentation: Encodable, Sendable { + public struct GroupedDocumentation: Sendable, Encodable { public let id: Int public let groupName: String public let documentations: Array diff --git a/Sources/RouteDocs/DocumentationDecoder.swift b/Sources/RouteDocs/DocumentationDecoder.swift index 36e5b14..60bdc44 100644 --- a/Sources/RouteDocs/DocumentationDecoder.swift +++ b/Sources/RouteDocs/DocumentationDecoder.swift @@ -12,9 +12,9 @@ extension Decoder { } } -public struct DocumentationObject: Hashable, CustomStringConvertible, Sendable { - public enum Body: Hashable, Sendable { - public struct EnumCase: Hashable, Sendable { +public struct DocumentationObject: Sendable, Hashable, CustomStringConvertible { + public enum Body: Sendable, Hashable { + public struct EnumCase: Sendable, Hashable { public let name: String? public let value: String @@ -62,7 +62,7 @@ public struct DocumentationObject: Hashable, CustomStringConvertible, Sendable { public let type: Any.Type public fileprivate(set) var body: Body - public var isOptional: Bool { type is AnyOptionalType.Type } + public var isOptional: Bool { type is any AnyOptionalType.Type } public var description: String { description(indentedBy: 0) } diff --git a/Sources/RouteDocs/EndpointDocumentation.swift b/Sources/RouteDocs/EndpointDocumentation.swift index 183c8f6..9f1ac3a 100644 --- a/Sources/RouteDocs/EndpointDocumentation.swift +++ b/Sources/RouteDocs/EndpointDocumentation.swift @@ -1,6 +1,6 @@ import Vapor -public struct DocumentationType: Codable, Equatable, CustomStringConvertible, Sendable { +public struct DocumentationType: Sendable, Equatable, Codable, CustomStringConvertible { public let typeDescription: TypeDescription public let customName: String? @@ -13,18 +13,18 @@ public struct DocumentationType: Codable, Equatable, CustomStringConvertible, Se fileprivate init(parsing type: Any.Type) { let actualType = _leafType(of: _openOptionals(in: type)) typeDescription = .init(any: actualType) - customName = (actualType as? CustomDocumentationNamed.Type)?.documentationName + customName = (actualType as? any CustomDocumentationNamed.Type)?.documentationName } } -public struct EndpointDocumentation: Codable, Equatable, CustomStringConvertible, Sendable { - public struct Object: Codable, Equatable, CustomStringConvertible, Sendable { - public enum Body: Codable, Equatable, CustomStringConvertible, Sendable { +public struct EndpointDocumentation: Sendable, Equatable, Codable, CustomStringConvertible { + public struct Object: Sendable, Equatable, Codable, CustomStringConvertible { + public enum Body: Sendable, Equatable, Codable, CustomStringConvertible { private enum CodingKeys: String, CodingKey { case isEmpty, fields, cases } - public struct Field: Codable, Equatable, CustomStringConvertible, Sendable { + public struct Field: Sendable, Equatable, Codable, CustomStringConvertible { public let name: String public let type: DocumentationType public let isOptional: Bool @@ -32,7 +32,7 @@ public struct EndpointDocumentation: Codable, Equatable, CustomStringConvertible public var description: String { "\(name): \(type)\(isOptional ? "?" : "")" } } - public struct EnumCase: Codable, Equatable, CustomStringConvertible, Sendable { + public struct EnumCase: Sendable, Equatable, Codable, CustomStringConvertible { public let name: String? public let value: String @@ -77,7 +77,7 @@ public struct EndpointDocumentation: Codable, Equatable, CustomStringConvertible } } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) if try container.decode(Bool.self, forKey: .isEmpty) { self = .empty @@ -88,7 +88,7 @@ public struct EndpointDocumentation: Codable, Equatable, CustomStringConvertible } } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) switch self { case .empty: @@ -150,7 +150,7 @@ public struct EndpointDocumentation: Codable, Equatable, CustomStringConvertible } } - public struct Query: Codable, Equatable, CustomStringConvertible, Sendable { + public struct Query: Sendable, Equatable, Codable, CustomStringConvertible { public let objects: Array public var description: String { @@ -168,7 +168,7 @@ public struct EndpointDocumentation: Codable, Equatable, CustomStringConvertible } } - public struct Payload: Codable, Equatable, CustomStringConvertible, @unchecked Sendable { // unchecked because of HTTPMediaType + public struct Payload: Equatable, Codable, CustomStringConvertible, @unchecked Sendable { // unchecked because of HTTPMediaType public let mediaType: HTTPMediaType public let objects: Array @@ -312,7 +312,7 @@ fileprivate extension RangeReplaceableCollection where Element: Equatable { } fileprivate func _openOptionals(in type: Any.Type) -> Any.Type { - (type as? AnyOptionalType.Type).map { _openOptionals(in: $0.anyWrappedType) } ?? type + (type as? any AnyOptionalType.Type).map { _openOptionals(in: $0.anyWrappedType) } ?? type } fileprivate func _leafType(of type: Any.Type) -> Any.Type { diff --git a/Sources/RouteDocs/TypeDescription.swift b/Sources/RouteDocs/TypeDescription.swift index 802b0e5..ba11198 100644 --- a/Sources/RouteDocs/TypeDescription.swift +++ b/Sources/RouteDocs/TypeDescription.swift @@ -1,10 +1,10 @@ -public struct TypeDescription: Hashable, Sendable, Codable, CustomStringConvertible { +public struct TypeDescription: Sendable, Hashable, Codable, CustomStringConvertible { private enum CodingKeys: String, CodingKey { case module, parent, name case genericParameters = "generic_parameters" } - private enum _ParentStorage: Hashable, Sendable { + private enum _ParentStorage: Sendable, Hashable { case none indirect case some(TypeDescription)