Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@oaSchemaProp example fails with numerical strings #1417

Closed
mneumann opened this issue May 10, 2021 · 6 comments · Fixed by #1419
Closed

@oaSchemaProp example fails with numerical strings #1417

mneumann opened this issue May 10, 2021 · 6 comments · Fixed by #1419
Assignees
Labels
bug Something isn't working

Comments

@mneumann
Copy link

Describe the bug

When using @oaSchemaProp example, providing a numerical string like "123.3" for a String type fails:

 /**
   * @oaSchemaProp example
   * "123.3"
   */
  amount: String;
Error: property type is wrong or property not allowed
    at Object.extractJSDocSchemaProps (.../api-spec/node_modules/@airtasker/spot/build/lib/src/parsers/schemaprop-parser.js:116:31)

As "123.3" is a String, this should work.

@Thodin3
Copy link
Contributor

Thodin3 commented May 11, 2021

Ok I can fix this one

Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
@Thodin3
Copy link
Contributor

Thodin3 commented May 11, 2021

There is also some other linked issues :
When using @oaSchemaProp default for Date or DateTime type it fails:

/** property-schemaprop date
   * @oaSchemaProp example
   * "1990-12-31"
   *  */
  "property-with-date": Date;

When using @oaSchemaProp example for Object or Array type it fails:

/** property-schemaprop array of integer
   * @oaSchemaProp example
   * [1990,12,31]
   *  */
  "property-with-array": Integer[];

When using @oaSchemaProp example for Union or Intersection type it fails:

/** property-schemaprop union of string
* @oaSchemaProp example
* "WAITING"
*  */
code?: "VALID" | "NOT_VALID" | "WAITING" | "APPROVED";

@Thodin3
Copy link
Contributor

Thodin3 commented May 11, 2021

Proposal :
in function extractJSDocSchemaProps(
const typeOf will be refactor and will use the JSON.parse real type instead of regexp filtering.

Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
Thodin3 added a commit to Thodin3/spot that referenced this issue May 11, 2021
@lfportal lfportal added the bug Something isn't working label May 11, 2021
lfportal pushed a commit that referenced this issue May 11, 2021
@amoghsharma1996
Copy link

Examples seem to work fine now, but the default oaSchemaProp seems busted for enum strings.

For example

  /** Status
   * @oaSchemaProp default
   * "Active"
   */
  // prettier-ignore
  status: "Active" | "Closed"

Throws an error

@Thodin3
Copy link
Contributor

Thodin3 commented Dec 19, 2021

Hello @amoghsharma1996,

It's seems to be a bug.
Normally this is same check rules for both example and default.
Could you try @default instead of @oaSchemaProp default?
@default is on one line.

@amoghsharma1996
Copy link

amoghsharma1996 commented Dec 21, 2021

Hey @Thodin3 same issue trying default.

Whether I try it on 1 line versus 2 lines:

@default "Active"
or

@default
"Active"

In either scenario I still receive the same error,
Error: property must be compliant with union type or property not allowed

I have opened up an issue to track this #1761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants