Skip to content

Commit 957339f

Browse files
committed
README tweaks
1 parent c85726a commit 957339f

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ OpenAPIKit follows semantic versioning despite the fact that the OpenAPI specifi
4141
- [Semantic Diffing of OpenAPI Documents](#semantic-diffing-of-openapi-documents)
4242
- [Notes](#notes)
4343
- [Contributing](#contributing)
44-
- [Security](#security)
44+
- [Security](#project-security)
4545
- [Specification Coverage & Type Reference](#specification-coverage--type-reference)
4646

4747
## Usage
@@ -348,15 +348,16 @@ struct ExampleLoader: ExternalLoader {
348348
typealias Message = Void
349349

350350
static func load<T>(_ url: URL) async throws -> (T, [Message]) where T : Decodable {
351-
// load data from file, perhaps. we will just mock that up for the test:
351+
// load data from file, perhaps. we will just mock that up for the example:
352352
let data = try await mockData(componentKey(type: T.self, at: url))
353353

354354
// We use the YAML decoder purely for order-stability.
355355
let decoded = try YAMLDecoder().decode(T.self, from: data)
356356
let finished: T
357357
// while unnecessary, a loader may likely want to attatch some extra info
358-
// to keep track of where a reference was loaded from. This test makes sure
359-
// the following strategy of using vendor extensions works.
358+
// to keep track of where a reference was loaded from. This example
359+
shows
360+
// the strategy of using vendor extensions.
360361
if var extendable = decoded as? VendorExtendable {
361362
extendable.vendorExtensions["x-source-url"] = AnyCodable(url)
362363
finished = extendable as! T
@@ -368,6 +369,7 @@ struct ExampleLoader: ExternalLoader {
368369

369370
static func componentKey<T>(type: T.Type, at url: URL) throws -> OpenAPIKit.OpenAPI.ComponentKey {
370371
// do anything you want here to determine what key the new component should be stored at.
372+
//
371373
// for the example, we will just transform the URL path into a valid components key:
372374
let urlString = url.pathComponents
373375
.joined(separator: "_")
@@ -386,7 +388,7 @@ In addition to looking something up in the [`Components`](https://mattpolzin.git
386388

387389
You use a value's [`dereferenced(in:)`](https://mattpolzin.github.io/OpenAPIKit/documentation/openapikit/locallydereferenceable) method to fully dereference it.
388390

389-
You can even dereference the whole document with the `OpenAPI.Document` `locallyDereferenced()` method. As the name implies, you can only derefence whole documents that are contained within one file (which is another way of saying that all references are "local"). Specifically, all references must be located within the document's Components Object. External dereferencing is done as a separeate step, but you can first dereference externally and then dereference internally if you'd like to perform both.
391+
You can even dereference the whole document with the `OpenAPI.Document` `locallyDereferenced()` method. As the name implies, you can only derefence whole documents that have previously been externally dereferenced (or documents contained within one file) -- that is, all references are "local". Specifically, all references must be located within the document's Components Object. External dereferencing is done as a separeate step, but you can first dereference externally and then dereference internally if you'd like to perform both.
390392

391393
Unlike what happens when you lookup an individual component using the `lookup()` method on `Components`, dereferencing a whole `OpenAPI.Document` will result in type-level changes that guarantee all references are removed. `OpenAPI.Document`'s `locallyDereferenced()` method returns a `DereferencedDocument` which exposes `DereferencedPathItem`s which have `DereferencedParameter`s and `DereferencedOperation`s and so on.
392394

@@ -458,7 +460,7 @@ The [**Swift Package Registry API Docs**](https://github.com/mattt/swift-package
458460
[**OpenAPIDiff**](https://github.com/mattpolzin/OpenAPIDiff) is a library and a CLI that implements semantic diffing; that is, rather than just comparing two OpenAPI documents line-by-line for textual differences, it parses the documents and describes the differences in the two OpenAPI ASTs.
459461

460462
## Notes
461-
This library does *not* currently support file reading at all muchless following `$ref`s to other files and loading them in. You must read OpenAPI documentation into `Data` or `String` (depending on the decoder you want to use) and all references must be internal to the same file to be resolved.
463+
This library does *not* handle reading files from disk or otherwise. You must read OpenAPI documentation into `Data` or `String` (depending on the decoder you want to use) and then decode using OpenAPIKit's `Decodable` conformances.
462464

463465
This library *is* opinionated about a few defaults when you use the Swift types, however encoding and decoding stays true to the spec. Some key things to note:
464466

@@ -475,7 +477,7 @@ Contributions to OpenAPIKit are welcome and appreciated! The project is mostly m
475477

476478
Please see the [Contribution Guidelines](./CONTRIBUTING.md) for a few brief notes on contributing the the project.
477479

478-
## Security
480+
## Project Security
479481
The OpenAPIKit project takes code security seriously. As part of the Swift Server Workground incubation program, this project follows a shared set of standards around receiving, reporting, and reacting to security vulnerabilies.
480482

481483
Please see [Security](./SECURITY.md) for information on how to report vulnerabilities to the OpenAPIKit project and what to expect after you do.

0 commit comments

Comments
 (0)