jsonschema2md icon indicating copy to clipboard operation
jsonschema2md copied to clipboard

Possibility to also show which properties are required

Open fretchen opened this issue 1 year ago • 2 comments

Would it be possible to add an option that prints out the required properties of the jsonschema ? This would come in handy in numerous cases. Take for example the following simple schema:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Test schema",
  "description": "I am a test schema.",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Name of the person."
    },
    "lastName": {
      "type": "string",
      "description": "Last name of the person."
    },
    "address": {
      "type": "string",
      "description": "Where does the person live."
    }
  },
  "required": [
    "name",
    "lastName"
  ]
}

It gets currenty translated into the following markdown:

# Test schema

*I am a test schema.*

## Properties

- **`name`** *(string)*: Name of the person.
- **`lastName`** *(string)*: Last name of the person.
- **`address`** *(string)*: Where does the person live.

It would be nice if some kind of reference to the fact that two properties are required would be there. If this was already discussed and decided to be irrelevant sorry for the spam.

fretchen avatar Jul 19 '24 17:07 fretchen

You probably use an old version because it's already implemented!

sbrunner avatar Aug 07 '24 08:08 sbrunner

I think that I was able to reproduce the error on main.

In https://github.com/sbrunner/jsonschema2md/pull/18 you introduced the possibility to show required attributes. However, this only worked properly within the definitions keyword. Here the required keyword is on a higher level.

Within the PR #331 I also added test for the bug I tried to report here.

fretchen avatar Aug 07 '24 09:08 fretchen

I believe this should be closed with #331.

reteps avatar Feb 24 '25 03:02 reteps

@sbrunner Can you close this?

reteps avatar Apr 15 '25 06:04 reteps

Sure, thanks :-)

sbrunner avatar Apr 16 '25 09:04 sbrunner