Skip to content

Commit ce3284c

Browse files
committed
README tweaks
1 parent c85726a commit ce3284c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)