Skip to content

Commit

Permalink
airtasker#1417 Fix the example/default fails with numerical strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Thodin3 committed May 11, 2021
1 parent 3b3e47e commit 1fcb18f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/src/parsers/__spec-examples__/schemaprops.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Date, Integer } from "../../syntax";
import { Date, Integer, String } from "../../syntax";

type SchemaPropTests = {
/** property-schemaprop description
* @oaSchemaProp pattern
* "property-schemaprop-value"
* */
"property-with-schemaprop": string;
/**
* @oaSchemaProp example
* "123.3"
*/
"property-with-string": String;
/** property-two-schemaprops description
* @oaSchemaProp minimum
* 123
Expand Down
18 changes: 18 additions & 0 deletions lib/src/parsers/schemaprop-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ describe("schemaprop-parser", () => {
]);
});

test("successfully parses string example schemaprops on properties on type ParsedSchemaProps", () => {
const stringSchemaPropNode = getJsDocsFromPropertySignatures(
properties,
'"property-with-string"'
);
const retrieveStringSchemaProp = extractJSDocSchemaProps(
stringSchemaPropNode,
{
kind: TypeKind.STRING
}
);
expect(retrieveStringSchemaProp).toBeDefined();
expect(retrieveStringSchemaProp!.isOk).toBeTruthy();
expect(retrieveStringSchemaProp!.unwrapOrThrow()).toStrictEqual([
{ name: "example", value: "123.3" }
]);
});

test("successfully parses integer schemaprops on properties on type ParsedSchemaProps", () => {
const integerSchemaPropNode = getJsDocsFromPropertySignatures(
properties,
Expand Down

0 comments on commit 1fcb18f

Please sign in to comment.