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

Json Schema emitter doesn't make use of example decorator #3950

Closed
risabhds opened this issue Jul 23, 2024 Discussed in #3944 · 1 comment
Closed

Json Schema emitter doesn't make use of example decorator #3950

risabhds opened this issue Jul 23, 2024 Discussed in #3944 · 1 comment

Comments

@risabhds
Copy link

Discussed in #3944

Originally posted by risabhds July 23, 2024
I have the following typespec in my playground:

import "@typespec/json-schema";

using TypeSpec.JsonSchema;

@jsonSchema
namespace Schemas;

/** Description goes here */
@summary("Title goes here")
model Person {
  /** The person's name. */
  @example("John")
  name: string;

  /** Age in years which must be equal to or greater than zero. */
  @example(18)
  @minValue(0)
  age: integer;
}

But I don't get examples in the emitted json-schema.

What I desire is a json-schema with examples on the property:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "Person.json",
    "description": "Description goes here",
    "title": "Title goes here",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "description": "The person's name.",
            "examples": ["John"]
        },
        "age": {
            "type": "integer",
            "minimum": 0,
            "description": "Age in years which must be equal to or greater than zero.",
            "examples": [18]
        }
    },
    "required": [
        "name",
        "age"
    ]
}

How do I get examples in the emitted json-schema?

@risabhds
Copy link
Author

Duplicate of #3946.
Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant