-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into feat/cli/rich-errors
- Loading branch information
Showing
41 changed files
with
1,392 additions
and
1,735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**/__fixtures__/** | ||
/test-harness/**/*.yaml | ||
/packages/*/dist | ||
/packages/*/CHANGELOG.md |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default undefined; | ||
export const on = Function(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
import type { Format } from '@stoplight/spectral-core'; | ||
import { isPlainObject } from '@stoplight/json'; | ||
|
||
type MaybeAsyncApi2 = Partial<{ asyncapi: unknown }>; | ||
type MaybeAAS2 = { asyncapi: unknown } & Record<string, unknown>; | ||
|
||
const bearsAStringPropertyNamed = (document: unknown, propertyName: string): boolean => { | ||
return isPlainObject(document) && propertyName in document && typeof document[propertyName] === 'string'; | ||
}; | ||
const aas2Regex = /^2\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/; | ||
const aas2_0Regex = /^2\.0(?:\.[0-9]*)?$/; | ||
const aas2_1Regex = /^2\.1(?:\.[0-9]*)?$/; | ||
const aas2_2Regex = /^2\.2(?:\.[0-9]*)?$/; | ||
const aas2_3Regex = /^2\.3(?:\.[0-9]*)?$/; | ||
|
||
const version2Regex = /^2\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/; | ||
const isAas2 = (document: unknown): document is { asyncapi: string } & Record<string, unknown> => | ||
isPlainObject(document) && 'asyncapi' in document && aas2Regex.test(String((document as MaybeAAS2).asyncapi)); | ||
|
||
export const asyncApi2: Format = document => { | ||
if (!bearsAStringPropertyNamed(document, 'asyncapi')) { | ||
return false; | ||
} | ||
export const aas2: Format = isAas2; | ||
aas2.displayName = 'AsyncAPI 2.x'; | ||
|
||
const version = String((document as MaybeAsyncApi2).asyncapi); | ||
// for backward compatibility | ||
export const asyncApi2 = aas2; | ||
export const asyncapi2 = aas2; | ||
|
||
return version2Regex.test(version); | ||
}; | ||
export const aas2_0: Format = (document: unknown): boolean => | ||
isAas2(document) && aas2_0Regex.test(String((document as MaybeAAS2).asyncapi)); | ||
aas2_0.displayName = 'AsyncAPI 2.0.x'; | ||
|
||
asyncApi2.displayName = 'AsyncAPI 2.x'; | ||
export const aas2_1: Format = (document: unknown): boolean => | ||
isAas2(document) && aas2_1Regex.test(String((document as MaybeAAS2).asyncapi)); | ||
aas2_1.displayName = 'AsyncAPI 2.1.x'; | ||
|
||
export { asyncApi2 as asyncapi2 }; | ||
export const aas2_2: Format = (document: unknown): boolean => | ||
isAas2(document) && aas2_2Regex.test(String((document as MaybeAAS2).asyncapi)); | ||
aas2_2.displayName = 'AsyncAPI 2.2.x'; | ||
|
||
export const aas2_3: Format = (document: unknown): boolean => | ||
isAas2(document) && aas2_3Regex.test(String((document as MaybeAAS2).asyncapi)); | ||
aas2_3.displayName = 'AsyncAPI 2.3.x'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,41 @@ | ||
export { default as alphabetical, Options as AlphabeticalOptions } from './alphabetical'; | ||
export { default as casing, Options as CasingOptions } from './casing'; | ||
export { default as defined } from './defined'; | ||
export { default as enumeration, Options as EnumerationOptions } from './enumeration'; | ||
export { default as falsy } from './falsy'; | ||
export { default as length, Options as LengthOptions } from './length'; | ||
export { default as pattern, Options as PatternOptions } from './pattern'; | ||
export { default as schema, Options as SchemaOptions } from './schema'; | ||
export { default as truthy } from './truthy'; | ||
export { default as undefined } from './undefined'; | ||
export { | ||
import { default as alphabetical, Options as AlphabeticalOptions } from './alphabetical'; | ||
import { default as casing, Options as CasingOptions } from './casing'; | ||
import { default as defined } from './defined'; | ||
import { default as enumeration, Options as EnumerationOptions } from './enumeration'; | ||
import { default as falsy } from './falsy'; | ||
import { default as length, Options as LengthOptions } from './length'; | ||
import { default as pattern, Options as PatternOptions } from './pattern'; | ||
import { default as schema, Options as SchemaOptions } from './schema'; | ||
import { default as truthy } from './truthy'; | ||
import { default as undefined } from './undefined'; | ||
import { | ||
default as unreferencedReusableObject, | ||
Options as UnreferencedReusableObjectOptions, | ||
} from './unreferencedReusableObject'; | ||
export { default as xor, Options as XorOptions } from './xor'; | ||
import { default as xor, Options as XorOptions } from './xor'; | ||
|
||
export { | ||
alphabetical, | ||
casing, | ||
defined, | ||
enumeration, | ||
falsy, | ||
length, | ||
pattern, | ||
schema, | ||
truthy, | ||
undefined, | ||
unreferencedReusableObject, | ||
xor, | ||
}; | ||
|
||
export type { | ||
AlphabeticalOptions, | ||
CasingOptions, | ||
EnumerationOptions, | ||
LengthOptions, | ||
PatternOptions, | ||
SchemaOptions, | ||
UnreferencedReusableObjectOptions, | ||
XorOptions, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.