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

[Bug]: JSON Schema emitter drops indentation of fenced code blocks inside of doc comments (/** */) #3370

Closed
4 tasks done
Veetaha opened this issue May 16, 2024 · 0 comments · Fixed by #3399
Closed
4 tasks done
Labels
bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core
Milestone

Comments

@Veetaha
Copy link
Contributor

Veetaha commented May 16, 2024

Describe the bug

See reproduction below.

Reproduction

Take this main.tsp TSP file as an example.

/**
 * ```toml
 * deny = [
 *     { name = "simple" },
 *     { name = "simple", version = "*" },
 *     { name = "simple", wrappers = ["example"] }
 * ]
 * ```
 */
@jsonSchema("my-domain.ua")
scalar PackageSpec extends string;

Run tsp compile . with the JSON schema emitter configured.
Then you'll get the following output:

type: string
description: |-
  ```toml
  deny = [
  { name = "simple" },
  { name = "simple", version = "*" },
  { name = "simple", wrappers = ["example"] }
  ]
  ```
$schema: https://json-schema.org/draft/2020-12/schema
$id: my-domain.ua

Notice how indentation inside of the TOML fenced code block got messed up in the description field of the schema.

Workaround

As a workaround it's possible to use the verbose @doc() syntax with """ a multiline string """. It preserves the indentation just fine.

Checklist

@Veetaha Veetaha added the bug Something isn't working label May 16, 2024
@markcowl markcowl added this to the [2024] June milestone May 20, 2024
github-merge-queue bot pushed a commit that referenced this issue May 20, 2024
Fixes #3370.

This also updates the generated documentation and typescript code to fix
lack of indentation on existing fenced blocks in this repo.

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants