Skip to content

Commit c968fce

Browse files
committed
Add new optional stricter reference validations that assert the references are found in the components object if internal
1 parent 79d3bc2 commit c968fce

1 file changed

Lines changed: 120 additions & 0 deletions

File tree

Sources/OpenAPIKit/Validator/Validation+Builtins.swift

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,126 @@ extension Validation {
199199
)
200200
}
201201

202+
/// Validate that all internal OpenAPI JSONSchema references are found in
203+
/// the document's components dictionary.
204+
///
205+
/// - See also: The similar but distinct default-on validation
206+
/// `schemaReferencesAreValid`.
207+
///
208+
/// - Important: This is not an included in validation by default.
209+
///
210+
public static var schemaReferencesFoundInComponents: Validation<OpenAPI.Reference<JSONSchema>> {
211+
References.schemaReferencesAreValid(mustPointToComponents: true)
212+
}
213+
214+
/// Validate that all internal JSONSchema references are found in the
215+
/// document's components dictionary.
216+
///
217+
/// - See also: The similar but distinct default-on validation
218+
/// `jsonSchemaReferencesAreValid`.
219+
///
220+
/// - Important: This is not an included in validation by default.
221+
///
222+
public static var jsonSchemaReferencesFoundInComponents: Validation<JSONSchema> {
223+
References.jsonSchemaReferencesAreValid(mustPointToComponents: true)
224+
}
225+
226+
/// Validate that all internal Response references are found in the
227+
/// document's components dictionary.
228+
///
229+
/// - See also: The similar but distinct default-on validation
230+
/// `responseReferencesAreValid`.
231+
///
232+
/// - Important: This is not an included in validation by default.
233+
///
234+
public static var responseReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Response>> {
235+
References.responseReferencesAreValid(mustPointToComponents: true)
236+
}
237+
238+
/// Validate that all internal Parameter references are found in the
239+
/// document's components dictionary.
240+
///
241+
/// - See also: The similar but distinct default-on validation
242+
/// `parameterReferencesAreValid`.
243+
///
244+
/// - Important: This is not an included in validation by default.
245+
///
246+
public static var parameterReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Parameter>> {
247+
References.parameterReferencesAreValid(mustPointToComponents: true)
248+
}
249+
250+
/// Validate that all internal Example references are found in the
251+
/// document's components dictionary.
252+
///
253+
/// - See also: The similar but distinct default-on validation
254+
/// `exampleReferencesAreValid`.
255+
///
256+
/// - Important: This is not an included in validation by default.
257+
///
258+
public static var exampleReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Example>> {
259+
References.exampleReferencesAreValid(mustPointToComponents: true)
260+
}
261+
262+
/// Validate that all internal Request references are found in the
263+
/// document's components dictionary.
264+
///
265+
/// - See also: The similar but distinct default-on validation
266+
/// `requestReferencesAreValid`.
267+
///
268+
/// - Important: This is not an included in validation by default.
269+
///
270+
public static var requestReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Request>> {
271+
References.requestReferencesAreValid(mustPointToComponents: true)
272+
}
273+
274+
/// Validate that all internal Header references are found in the
275+
/// document's components dictionary.
276+
///
277+
/// - See also: The similar but distinct default-on validation
278+
/// `headerReferencesAreValid`.
279+
///
280+
/// - Important: This is not an included in validation by default.
281+
///
282+
public static var headerReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Header>> {
283+
References.headerReferencesAreValid(mustPointToComponents: true)
284+
}
285+
286+
/// Validate that all internal Link references are found in the document's
287+
/// components dictionary.
288+
///
289+
/// - See also: The similar but distinct default-on validation
290+
/// `linkReferencesAreValid`.
291+
///
292+
/// - Important: This is not an included in validation by default.
293+
///
294+
public static var linkReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Link>> {
295+
References.linkReferencesAreValid(mustPointToComponents: true)
296+
}
297+
298+
/// Validate that all internal Callbacks references are found in the
299+
/// document's components dictionary.
300+
///
301+
/// - See also: The similar but distinct default-on validation
302+
/// `callbacksReferencesAreValid`.
303+
///
304+
/// - Important: This is not an included in validation by default.
305+
///
306+
public static var callbacksReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.Callbacks>> {
307+
References.callbacksReferencesAreValid(mustPointToComponents: true)
308+
}
309+
310+
/// Validate that all internal PathItem references are found in the
311+
/// document's components dictionary.
312+
///
313+
/// - See also: The similar but distinct default-on validation
314+
/// `pathItemReferencesAreValid`.
315+
///
316+
/// - Important: This is not an included in validation by default.
317+
///
318+
public static var pathItemReferencesFoundInComponents: Validation<OpenAPI.Reference<OpenAPI.PathItem>> {
319+
References.pathItemReferencesAreValid(mustPointToComponents: true)
320+
}
321+
202322
// MARK: - Included with `Validator()` by default
203323

204324
// You can start with no validations (not even the defaults below)

0 commit comments

Comments
 (0)