Giter VIP home page Giter VIP logo

Comments (5)

gregsdennis avatar gregsdennis commented on May 20, 2024

Have you read the documentation?

https://docs.json-everything.net/schema/schemagen/schema-generation/#schema-schemagen-nullability

The attribute you're looking for is [Required]. I can support more with this attribute than what [JsonRequired] offers.

from json-everything.

kostyrin avatar kostyrin commented on May 20, 2024

Due to Required Attribure is more specific for Json.Schema.Generation. I would prefer to use mostly using System.Text.Json.Serialization.JsonRequiredAttribute like System.Text.Json.Serialization.JsonPropertyNameAttribute. It's more make sense.

from json-everything.

gregsdennis avatar gregsdennis commented on May 20, 2024

I don't understand your question then. How do you want to use the [JsonRequired] attribute?

System.Text.Json.Serialization.JsonRequiredAttribute doesn't support the functionality I need for schema generation, so I had to make a new attribute.

from json-everything.

kostyrin avatar kostyrin commented on May 20, 2024

just after evaluation should be contained errors due to RequiredString is marked as required with JsonRequired attribute. is it possible?

from json-everything.

gregsdennis avatar gregsdennis commented on May 20, 2024

Your issue is in the schema generation, which doesn't recognize [JsonRequired] (and I'm not inclined to add support for it). You need to use the [Required] that's supplied with the generation library.

class MyClass
{
    [Required]
    [JsonRequired]
    public string RequiredString { get; set; }
}

This will add the required keyword to the schema, which will create an error.

from json-everything.

Related Issues (20)

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.