Git Product home page Git Product logo

deprecated-json-schema-2-poco's People

Contributors

bitfrost avatar brentryan avatar bscscorm avatar codedemonuk avatar lroling8350 avatar sbl03 avatar stefh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deprecated-json-schema-2-poco's Issues

Improve error message when title is missing from a schema

I tried to generate poco's based off a schema that didn't have a title property, and the executable errored out with this stacktrace:

Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: key at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at Cvent.JsonSchema2Poco.JsonSchema2Poco.GetUniqueSchemaClasses(JsonSchemaClass jsonClass, Dictionary2 uniqueClassesById, Dictionary2 uniqueClassesByName) at Cvent.JsonSchema2Poco.JsonSchema2Poco.GetUniqueSchemaClasses(IEnumerable1 schemas) at Cvent.JsonSchema2Poco.JsonSchema2Poco.Generate(IGenerationConfig configuration) at Cvent.JsonSchema2Poco.Program.Main(String[] args)

Preferably it should detect this is missing and throw a more informative error message.

The "required" property is not supported ?

When using this Basic example schema on : http://json-schema.org/examples.html

{
    "title": "Example Schema",
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string"
        },
        "lastName": {
            "type": "string"
        },
        "age": {
            "description": "Age in years",
            "type": "integer",
            "minimum": 0
        }
    },
    "required": ["firstName", "lastName"]
}

The software generates this error:

2015-06-16 21:19:15.1404 [Error] Could not parse the schema: file:///c:/temp/jschema.json
Make sure your schema is compatible.Examine the stack trace below.
2015-06-16 21:19:15.1603 [Fatal] System.ArgumentException: Can not convert Array to Boolean.
   at Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value)
   at Newtonsoft.Json.Schema.JsonSchemaBuilder.ProcessSchemaProperties(JObject schemaObject)
   at Newtonsoft.Json.Schema.JsonSchemaBuilder.BuildSchema(JToken token)
   at Newtonsoft.Json.Schema.JsonSchemaBuilder.Read(JsonReader reader)
   at Newtonsoft.Json.Schema.JsonSchema.Read(JsonReader reader, JsonSchemaResolver resolver)
   at Newtonsoft.Json.Schema.JsonSchema.Parse(String json, JsonSchemaResolver resolver)
   at Cvent.SchemaToPoco.Core.JsonSchemaResolver.ResolveSchemaHelper(Uri curr, Uri parent, String data) in C:\Users\Stef\Documents\Github\forks\json-schema-2-poco

extends on single line, "title" is ignored

if you use a title with extends, and extends is on one single line like:
"extends": { "$ref": "requestBase.json"},

with a 'title' element,
the class name is 'DefaultClassName.cs'
instead of what is given in 'title.'

The workaround is to make the extends use multiple lines, and the class name then correctly matches the title.

Support attributes required for JSON.net deserialization

Currently, all the validation attributes are made for validation with ASP.NET WebAPI. They come from the System.ComponentModel.DataAnnotations namespace. To make the attributes work when deserializing with JSON.net, the attributes must be under the JsonProperty attribute.

Example: Currently, a required attribute looks like this:

[Required()]

To be deserializable with JSON.net, it must look like this:

[JsonProperty(Required = Required.Always)]

An option should be given to decide which set of attributes to use.


Relevant SO.
WebAPI Validation.

Circular references do not work

Example: schema1 has a $ref to schema2, and schema2 has a $ref to schema1.

Cause: ResolveSchemas in Program.cs resolves references by scanning through the file for .json and recursively calls itself.

No License information

This repository has no license information included, which limits the benefit of sharing it publicly here as people may avoid using it to avoid facing legal issues.

If you intend to allow this code to be used freely, it would be helpful if you could select an open source license and note you are releasing the code under that license: http://opensource.org/licenses. (If that's not your intention, it would be helpful to note that as well!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.