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

JSDoc tags for Object and Record types #842

Closed
jakubpavlicko22 opened this issue Oct 12, 2023 · 3 comments
Closed

JSDoc tags for Object and Record types #842

jakubpavlicko22 opened this issue Oct 12, 2023 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@jakubpavlicko22
Copy link

Description

The parser doesn't include JSDoc tags in the schema for Object and Record types.

From the example below, you can see that property title which is of type string has non-empty x-typia-jsDocTags property as it should. But property foo as well as the whole type Test have x-typia-jsDocTags property empty despite having a JSDoc comment with title. The same thing happens with properties of type Record<A,B>.

Example

/**
 * @title Test Object
 */
export type Test = 
{
    /**
     * @title Test Title
     */
    title: string

    /**
     * @title Foo
     */
    foo: {
        /**
         * @title Bar
         */
        bar: string
    }
}

Resulting schema components

{
  "Test": {
    "$id": "#/components/schemas/Test",
    "type": "object",
    "properties": {
      "title": {
        "title": "Test Title",
        "x-typia-jsDocTags": [
          {
            "name": "title",
            "text": [
              {
                "text": "Test Title",
                "kind": "text"
              }
            ]
          }
        ],
        "x-typia-required": true,
        "x-typia-optional": false,
        "type": "string"
      },
      "foo": {
        "$ref": "#/components/schemas/__type"
      }
    },
    "required": [
      "title",
      "foo"
    ],
    "x-typia-jsDocTags": []
  },
  "__type": {
    "$id": "#/components/schemas/__type",
    "type": "object",
    "properties": {
      "bar": {
        "title": "Bar",
        "x-typia-jsDocTags": [
          {
            "name": "title",
            "text": [
              {
                "text": "Bar",
                "kind": "text"
              }
            ]
          }
        ],
        "x-typia-required": true,
        "x-typia-optional": false,
        "type": "string"
      }
    },
    "required": [
      "bar"
    ],
    "x-typia-jsDocTags": []
  }
}
@samchon
Copy link
Owner

samchon commented Oct 12, 2023

This is exact what I have intended.

Hope to define an explicit object type.

@samchon samchon self-assigned this Oct 12, 2023
@samchon samchon added the wontfix This will not be worked on label Oct 12, 2023
@jakubpavlicko22
Copy link
Author

But it doesn't work with explicit object types either. See below when I add an explicit type

Example

/**
 * @title Test Object
 */
export type Test = 
{
    /**
     * @title Test Title
     */
    title: string

    /**
     * @title Foo
     */
    foo: FooType;
}

/**
 * @title Foo Object
 */
type FooType = {
    /**
     * @title Bar
     */
    bar: string
}

Schema

{
  "Test": {
    "$id": "#/components/schemas/Test",
    "type": "object",
    "properties": {
      "title": {
        "title": "Test Title",
        "x-typia-jsDocTags": [
          {
            "name": "title",
            "text": [
              {
                "text": "Test Title",
                "kind": "text"
              }
            ]
          }
        ],
        "x-typia-required": true,
        "x-typia-optional": false,
        "type": "string"
      },
      "foo": {
        "$ref": "#/components/schemas/FooType"
      }
    },
    "required": [
      "title",
      "foo"
    ],
    "x-typia-jsDocTags": []
  },
  "FooType": {
    "$id": "#/components/schemas/FooType",
    "type": "object",
    "properties": {
      "bar": {
        "title": "Bar",
        "x-typia-jsDocTags": [
          {
            "name": "title",
            "text": [
              {
                "text": "Bar",
                "kind": "text"
              }
            ]
          }
        ],
        "x-typia-required": true,
        "x-typia-optional": false,
        "type": "string"
      }
    },
    "required": [
      "bar"
    ],
    "x-typia-jsDocTags": []
  }
}

@samchon samchon added bug Something isn't working and removed wontfix This will not be worked on labels Oct 12, 2023
@samchon
Copy link
Owner

samchon commented Oct 12, 2023

Got it, no problem when using interface statement.

However, failed to catch the description and comment tags when using alias type statement.

@samchon samchon added enhancement New feature or request good first issue Good for newcomers labels Oct 12, 2023
samchon added a commit that referenced this issue Oct 12, 2023
Fix #842 - exact description comment tracing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants