-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: decode model schema name on model component (#8400)
Refs #5626
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
import Model from "../../../../src/core/components/model" | ||
|
||
describe("getModelName", () => { | ||
const model = new Model() | ||
|
||
it("should decode JSON Pointer and URI encoding for OpenAPI v3 refs", () => { | ||
const actual = model.getModelName("#/components/schemas/a~1b%2Bc") | ||
const expected = "a/b+c" | ||
|
||
expect(actual).toStrictEqual(expected) | ||
}) | ||
|
||
it("should decode JSON Pointer and URI encoding for Swagger v2 refs", () => { | ||
const actual = model.getModelName( | ||
"#/definitions/custom%3A%3Anamespace%3A%3APerson" | ||
) | ||
const expected = "custom::namespace::Person" | ||
|
||
expect(actual).toStrictEqual(expected) | ||
}) | ||
|
||
it("should decode multiple json-pointer values", () => { | ||
const actual = model.getModelName("#/components/schemas/~1~1~0~0") | ||
const expected = "//~~" | ||
|
||
expect(actual).toStrictEqual(expected) | ||
}) | ||
|
||
it("should support invalid URI encoding", () => { | ||
const actual = model.getModelName("#/components/schemas/%25%d") | ||
const expected = "%25%d" | ||
|
||
expect(actual).toStrictEqual(expected) | ||
}) | ||
}) |