1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
|
openapi: 3.0.3
info:
title: Swift Package Registry API
description: API for managing Swift package releases and interacting with the package registry.
version: 1.0.0
tags:
- name: Releases
- name: Packages
- name: Authentication
paths:
'/{scope}/{name}':
parameters:
- $ref: '#/components/parameters/Scope'
- $ref: '#/components/parameters/PackageName'
get:
tags:
- Releases
summary: List package releases
operationId: listPackageReleases
responses:
'200':
description: Retrieve a list of all available releases for a given package
headers:
Link:
$ref: '#/components/headers/PackageLinks'
Content-Version:
$ref: '#/components/headers/ContentVersion'
content:
'application/json':
schema:
$ref: '#/components/schemas/Releases'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'429':
$ref: '#/components/responses/TooManyRequests'
'/{scope}/{name}/{version}':
parameters:
- $ref: '#/components/parameters/Scope'
- $ref: '#/components/parameters/PackageName'
- $ref: '#/components/parameters/Version'
get:
tags:
- Releases
summary: Fetch metadata for a package release
operationId: fetchReleaseMetadata
responses:
'200':
description: Retrieve detailed metadata for a specific package release
headers:
Link:
$ref: '#/components/headers/PackageLinks'
Content-Version:
$ref: '#/components/headers/ContentVersion'
content:
'application/json':
schema:
$ref: '#/components/schemas/ReleaseMetadata'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'429':
$ref: '#/components/responses/TooManyRequests'
put:
tags:
- Releases
summary: Create a package release
operationId: createPackageRelease
parameters:
- in: header
name: X-Swift-Package-Signature-Format
description: The signature format if the source archive is signed.
schema:
type: string
example: 'cms-1.0.0'
- in: header
name: Prefer
description: |-
Communicates the preference for sync vs async processing.
Use "respond-async" to get async processing, for example "respond-async, wait=300" to wait up to 300 seconds.
Omit this header to prefer sync processing.
schema:
type: string
requestBody:
description: A multipart payload.
required: true
content:
multipart/form-data:
schema:
type: object
properties:
source-archive:
type: string
format: binary
description: The binary source archive of the package to be published
example: 'Binary data for Linked List package release'
source-archive-signature:
type: string
format: binary
description: The signature for the source archive.
metadata:
$ref: '#/components/schemas/PackageMetadata'
metadata-signature:
type: string
format: base64
description: The signature for the metadata.
required:
- source-archive
encoding:
source-archive:
contentType: application/zip
source-archive-signature:
contentType: application/octet-stream
metadata:
contentType: application/json
metadata-signature:
contentType: application/octet-stream
responses:
'201':
description: The package release has been successfully published
headers:
Content-Version:
$ref: '#/components/headers/ContentVersion'
Location:
description: The URL to the created release.
schema:
type: string
format: uri
example: 'https://packages.example.com/github.com/mona/LinkedList/1.1.1'
content:
'application/json':
schema:
$ref: '#/components/schemas/PublishResponse'
'202':
description: The request to publish the package has been accepted and is being processed
headers:
'Retry-After':
$ref: '#/components/headers/RetryAfter'
Location:
description: |-
The URL to poll for status of the publication process.
Poll that URL using a `GET` request, and if the response is 202, extract the Retry-After header to get a new estimate
of when the processing will be finished.
When the response is 301, the processing is finished and the Location header points to the new release.
If the response is 4xx, the processing failed and you can stop polling. The response contains the failure details.
Send `DELETE` to the URL to cancel the processing.
schema:
type: string
format: uri
description: URL to poll for status of the publication process
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'405':
description: Method not allowed - publishing is not supported on this server.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
'409':
description: Conflict - an existing release already exists, or the release is still processing.
headers:
Location:
description: The location of the release that's still processing, see the 202 response for details.
schema:
type: string
format: uri
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
'413':
description: Content too large.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'422':
description: Unprocessable entity - refused to publish the release.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
'429':
$ref: '#/components/responses/TooManyRequests'
'/{scope}/{name}/{version}/Package.swift':
parameters:
- $ref: '#/components/parameters/Scope'
- $ref: '#/components/parameters/PackageName'
- $ref: '#/components/parameters/Version'
get:
tags:
- Packages
summary: Fetch manifest for a package release
operationId: fetchManifestForPackageRelease
parameters:
- $ref: '#/components/parameters/SwiftVersion'
responses:
'200':
description: Retrieve the manifest file for the specified package release
headers:
Link:
required: true
schema:
type: string
description: |-
One value for each version-specific package manifest file in the release's source archive,
whose filename matches the following regular expression pattern:
`\APackage@swift-(\d+)(?:\.(\d+))?(?:\.(\d+))?.swift\z`
Each link value should have the alternate relation type, a filename attribute set to the version-specific package manifest filename
(for example, Package@swift-4.swift), and a swift-tools-version attribute set to the Swift tools version specified by the package
manifest file (for example, 4.0 for a manifest beginning with the comment // swift-tools-version:4.0).
content:
text/x-swift:
schema:
type: string
'303':
description: Redirect to the unqualified Package.swift resource.
headers:
Location:
required: true
schema:
type: string
format: uri
example: 'https://packages.example.com/mona/LinkedList/1.1.1/Package.swift'
Content-Version:
$ref: '#/components/headers/ContentVersion'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'429':
$ref: '#/components/responses/TooManyRequests'
'/{scope}/{name}/{version}.zip':
parameters:
- $ref: '#/components/parameters/Scope'
- $ref: '#/components/parameters/PackageName'
- $ref: '#/components/parameters/Version'
get:
tags:
- Packages
summary: Download source archive for a package release
operationId: downloadSourceArchive
responses:
'200':
description: Download the source archive for the specified package release
headers:
Digest:
description: A digest containing a cryptographic digest of the source archive.
schema:
type: string
example: 'sha-256=oqxUzyX7wa0AKPA/CqS5aDO4O7BaFOUQiSuyfepNyBI='
Content-Disposition:
description: |-
A header set to attachment with a filename parameter equal to the name of the package followed by a hyphen (-),
the version number, and file extension (for example, "LinkedList-1.1.1.zip")
schema:
type: string
example: 'attachment; filename="LinkedList-1.1.1.zip"'
X-Swift-Package-Signature-Format:
description: The format of the package signature, used for integrity verification
schema:
type: string
example: 'cms-1.0.0'
X-Swift-Package-Signature:
description: Signature of the downloaded package, used for integrity verification
schema:
type: string
format: base64
example: 'l1TdTeIuGdNsO1FQ0ptD64F5nSSOsQ5WzhM6/7KsHRuLHfTsggnyIWr0DxMcBj5F40zfplwntXAgS0ynlqvlFw=='
Link:
description: A header containing mirrors or multiple download locations.
schema:
type: string
description: A Link header with a `duplicate` relation, as described by RFC 6249.
example: '<https://mirror-japanwest.example.com/mona-LinkedList-1.1.1.zip>; rel=duplicate; geo=jp; pri=10; type="application/zip"'
content:
application/zip:
schema:
type: string
format: binary
'303':
description: See other - download from the URL in the Location header.
headers:
Location:
description: The location from which to download the resource.
required: true
schema:
type: string
example: 'https://example.cdn.com/LinkedList-1.1.1.zip?key=XXXXXXXXXXXXXXXXX'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'429':
$ref: '#/components/responses/TooManyRequests'
'/identifiers':
parameters:
- $ref: '#/components/parameters/Url'
get:
tags:
- Packages
summary: Lookup package identifiers registered for a URL
operationId: lookupPackageIdentifiersByURL
responses:
'200':
description: Retrieve a list of package identifiers registered for a specific URL
headers:
Content-Version:
$ref: '#/components/headers/ContentVersion'
content:
'application/json':
schema:
$ref: '#/components/schemas/Identifiers'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'415':
$ref: '#/components/responses/UnsupportedMediaType'
'429':
$ref: '#/components/responses/TooManyRequests'
'/login':
post:
tags:
- Authentication
summary: Log in to the package registry
operationId: loginToRegistry
description: |-
Log in using either basic or token authentication. Use the `Authorization` header to provide credentials.
Also use this endpoint to verify authentication credentials before saving them to the local secrets store.
responses:
'200':
description: User successfully logged in to the package registry
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/TooManyRequests'
'501':
description: Registry does not support authentication.
components:
parameters:
SwiftVersion:
name: swift-version
in: query
required: false
description: The Swift version for which to fetch the manifest
schema:
type: string
example: '4.2'
Scope:
name: scope
in: path
required: true
description: |-
The scope of the package (for example, the organization or user).
Package scopes are case-insensitive.
schema:
type: string
pattern: '[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}'
example: 'mona'
PackageName:
name: name
in: path
required: true
description: |-
The name of the package.
Package names are case-insensitive.
schema:
type: string
pattern: '[a-zA-Z0-9](?:[a-zA-Z0-9]|[-_](?=[a-zA-Z0-9])){0,99}'
example: 'LinkedList'
Version:
name: version
in: path
required: true
description: The semantic version of the package release.
schema:
type: string
example: '1.2.3'
Url:
name: url
in: query
required: true
description: The URL for which to look up registered package identifiers
schema:
type: string
example: 'https://example.com/mona/LinkedList'
responses:
Unauthorized:
description: Authentication failed due to invalid credentials provided
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
BadRequest:
description: Bad Request - The request was invalid or cannot be otherwise served
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
NotFound:
description: Not Found - The specified resource could not be found
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
UnsupportedMediaType:
description: Unsupported Media Type - Accept header specifies a valid but unsupported API version.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
TooManyRequests:
description: Too Many Requests - Rate limit exceeded
headers:
'Retry-After':
$ref: '#/components/headers/RetryAfter'
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetails'
headers:
PackageLinks:
schema:
type: string
description: |-
A set of related links.
An example:
<https://github.com/mona/LinkedList>; rel="canonical",
<ssh://git@github.com:mona/LinkedList.git>; rel="alternate",
<https://packages.example.com/mona/LinkedList/1.1.1>; rel="latest-version",
<https://github.com/sponsors/mona>; rel="payment",
<https://packages.example.com/mona/LinkedList?page=1>; rel="first",
<https://packages.example.com/mona/LinkedList?page=2>; rel="previous",
<https://packages.example.com/mona/LinkedList?page=4>; rel="next",
<https://packages.example.com/mona/LinkedList?page=10>; rel="last"
Another example:
<https://packages.example.com/mona/LinkedList/1.1.1>; rel="latest-version",
<https://packages.example.com/mona/LinkedList/1.0.0>; rel="predecessor-version"
Also see:
- https://www.rfc-editor.org/rfc/rfc6596.html
- https://html.spec.whatwg.org/multipage/links.html#link-type-alternate
- https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#4-endpoints
RetryAfter:
schema:
type: string
description: |-
Retry-After header, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After.
Examples:
Retry-After: Wed, 21 Oct 2015 07:28:00 GMT
Retry-After: 120
example: '120'
ContentVersion:
description: The content version.
required: true
schema:
type: integer
enum:
- 1
schemas:
PackageOrganization:
type: object
properties:
description:
description: A description of the organization.
type: string
email:
description: Email address of the organization.
format: email
type: string
name:
description: Name of the organization.
type: string
url:
description: URL of the organization.
format: uri
type: string
required:
- name
PackageAuthor:
type: object
properties:
description:
description: A description of the author.
type: string
email:
description: Email address of the author.
format: email
type: string
name:
description: Name of the author.
type: string
organization:
$ref: '#/components/schemas/PackageOrganization'
url:
description: URL of the author.
format: uri
type: string
required:
- name
PackageMetadata:
type: object
description: Metadata of a package release.
properties:
author:
$ref: '#/components/schemas/PackageAuthor'
description:
type: string
description: A description of the package release.
licenseURL:
type: string
format: uri
description: URL of the package release's license document.
originalPublicationTime:
type: string
format: date-time
description: Original publication time of the package release in ISO 8601 format.
readmeURL:
type: string
format: uri
description: URL of the README specifically for the package release or broadly
for the package.
repositoryURLs:
type: array
items:
description: Code repository URL.
type: string
format: uri
description: Code repository URL(s) of the package release.
PublishResponse:
type: object
properties:
message:
type: string
example: 'Package release successfully published'
url:
type: string
format: uri
description: The URL of the newly published package release
example: 'https://packages.example.com/mona/LinkedList/1.1.0'
ProblemDetails:
type: object
description: A problem detail object conforming to RFC7807
properties:
type:
type: string
format: uri
description: |-
A URI reference that identifies the problem type.
This specification encourages that, when dereferenced,
it provides human-readable documentation for the problem type.
example: 'https://example.com/problem/invalid-request-parameters'
title:
type: string
description: |-
A short, human-readable summary of the problem type.
It should not change from occurrence to occurrence of the
problem, except for purposes of localization.
example: 'Invalid request parameters'
status:
type: integer
description: |-
The HTTP status code generated by the origin server for this occurrence of the problem.
example: 400
detail:
type: string
description: A human-readable explanation specific to this occurrence of the problem.
example: 'The "name" field is required.'
instance:
type: string
format: uri
description: A URI reference that identifies the specific occurrence of the problem.
example: '/requests/12345'
additionalProperties: true
ListedRelease:
type: object
properties:
url:
type: string
format: uri
example: 'https://packages.example.com/mona/LinkedList/1.1.0'
problem:
$ref: '#/components/schemas/ProblemDetails'
Releases:
type: object
properties:
releases:
type: object
additionalProperties:
$ref: '#/components/schemas/ListedRelease'
required:
- releases
ReleaseSignature:
type: object
properties:
signatureBase64Encoded:
type: string
format: base64
description: The resource's signature, base64 encoded.
example: 'dGVzdFNpZ25hdHVyZQ=='
signatureFormat:
type: string
description: The signature format.
example: 'cms-1.0.0'
required:
- signatureBase64Encoded
- signatureFormat
ReleaseResource:
type: object
properties:
name:
type: string
description: The name of the resource.
example: 'source-archive'
type:
type: string
description: The content type of the resource.
example: 'application/zip'
checksum:
type: string
description: A hexadecimal representation of the SHA256 digest for the resource.
example: 'efaa6545cd99dd1e124b5269ea0586994b6d97a0443021d2966e1df6dec9c4a1'
signing:
$ref: '#/components/schemas/ReleaseSignature'
required:
- name
- type
- checksum
ReleaseMetadata:
type: object
properties:
id:
$ref: '#/components/schemas/Identifier'
version:
type: string
description: The package release version number.
example: '1.2.3'
resources:
type: array
items:
$ref: '#/components/schemas/ReleaseResource'
description: The resources available for the release.
metadata:
$ref: '#/components/schemas/PackageMetadata'
publishedAt:
type: string
format: date-time
description: |-
The ISO 8601-formatted datetime string of when the package release was published, as recorded by the registry.
See related `originalPublicationTime` in metadata.
required:
- id
- version
- resources
- metadata
Identifier:
type: string
example: 'mona.LinkedList'
Identifiers:
type: object
properties:
identifiers:
type: array
items:
$ref: '#/components/schemas/Identifier'
required:
- identifiers
|