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 from JSON-Data #1375

Closed
magicmarcy opened this issue Aug 13, 2024 · 6 comments
Closed

JSON Schema from JSON-Data #1375

magicmarcy opened this issue Aug 13, 2024 · 6 comments
Labels
extension idea An idea of tool / extension

Comments

@magicmarcy
Copy link

What feature or new tool do you think should be added to DevToys?

We already have some JSON tools in the DevToys, all of which I consider to be really useful. What I personally am still missing is a converter that creates a JSON schema from JSON data. An example of how this works can be found here: like: https://www.liquid-technologies.com/online-json-to-schema-converter

Why do you think this is needed?

I use JSON schemas primarily for testing endpoints. This allows me to verify that all properties are still being returned as expected and that no one has changed the data types or other things.

Solution/Idea

Sample-Input:

{
  "name": "Alice",
  "age": 24,
  "address": {
    "street": "Main Str.",
    "no": 12,
    "postcode": "1234"
  },
  "gender": "FEMALE"
}

Sample-Output:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "age": {
      "type": "integer"
    },
    "address": {
      "type": "object",
      "properties": {
        "street": {
          "type": "string"
        },
        "no": {
          "type": "integer"
        },
        "postcode": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "street",
        "no",
        "postcode"
      ]
    },
    "gender": {
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "age",
    "address",
    "gender"
  ]
}

Comments

No response

@magicmarcy magicmarcy added feature Feature / Tool request or idea untriaged labels Aug 13, 2024
@veler
Copy link
Collaborator

veler commented Aug 13, 2024

HI,
I wonder if this could be added to the JSON Schema extension made by @benyaa ?

@benyaa
Copy link

benyaa commented Aug 13, 2024

HI, I wonder if this could be added to the JSON Schema extension made by @benyaa ?

I believe it can, although I'm not sure it should be part of the Json schema validator as it is a tester and this feature is a generator. But it shouldn't take that long to make one, it would have the same GUI and use the same library to accomplish this.

@veler
Copy link
Collaborator

veler commented Aug 13, 2024

Indeed. I would suggest to make it a separated tool, and either in the same extension, or in a new one.
If both use the same library to handle the json schema, it may be better to keep it in the same extension.

@benyaa
Copy link

benyaa commented Aug 13, 2024

okay, I spent the last hour implementing it and added another tool on top of it to generate classes out of json schemas. NJsonSchema is just wonderful

@magicmarcy
Copy link
Author

okay, I spent the last hour implementing it and added another tools on top of it to generate classes out of json schemas. NJsonSchema is just wonderful

Wow, this is really awesome and exactly what I've been looking for! Thank you so much!

@veler
Copy link
Collaborator

veler commented Aug 13, 2024

okay, I spent the last hour implementing it and added another tools on top of it to generate classes out of json schemas. NJsonSchema is just wonderful

Wow wow wow that was quick! 😁👏 Thank you so much!

@veler veler added extension idea An idea of tool / extension and removed feature Feature / Tool request or idea untriaged labels Aug 13, 2024
@veler veler closed this as completed Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension idea An idea of tool / extension
Projects
None yet
Development

No branches or pull requests

3 participants