-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reference): change Reference from stamp to TypeScript class (#4099)
Refs #3481 BREAKING CHANGE: Reference from apidom-reference package became a class and requires to be instantiated with new operator.
- Loading branch information
Showing
19 changed files
with
136 additions
and
126 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
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,25 +1,32 @@ | ||
import stampit from 'stampit'; | ||
|
||
import { Reference as IReference } from './types'; | ||
|
||
const Reference: stampit.Stamp<IReference> = stampit({ | ||
props: { | ||
uri: '', | ||
value: null, | ||
depth: 0, | ||
refSet: null, | ||
errors: [], | ||
}, | ||
init( | ||
this: IReference, | ||
{ depth = this.depth, refSet = this.refSet, uri = this.uri, value = this.value } = {}, | ||
) { | ||
import { Element } from '@swagger-api/apidom-core'; | ||
|
||
import { ReferenceSet } from './types'; | ||
|
||
export interface ReferenceOptions<T = Element> { | ||
readonly uri: string; | ||
readonly depth?: number; | ||
readonly refSet?: ReferenceSet; | ||
readonly value: T; | ||
} | ||
|
||
class Reference<T = Element> { | ||
public readonly uri: string; | ||
|
||
public readonly depth: number; | ||
|
||
public readonly value: T; | ||
|
||
public refSet?: ReferenceSet; | ||
|
||
public readonly errors: Array<Error>; | ||
|
||
constructor({ uri, depth = 0, refSet, value }: ReferenceOptions<T>) { | ||
this.uri = uri; | ||
this.value = value; | ||
this.depth = depth; | ||
this.refSet = refSet; | ||
this.errors = []; | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export default Reference; |
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
Oops, something went wrong.