Comments (4)
Thinking of looking into this for Hacktoberfest. Any pointers?
from saunter.
We generate a Document which contains Messages, each message has a Payload.
This ISchema
is in JSON-Schema format.
When we set the Schema.Type
property (which is currently a string) by reflecting types in the SchemaGenerator
.
An example of a simple schema representing a non-nullable int:
{
"type": "integer"
}
An example representing a nullable int:
{
"type": ["integer", "null"]
}
We need to make Schema.Type
render as either a string "T"
, or if the type is nullable, an array containing [ "T", "null" ]
.
We can optionally/additionally support the OpenAPI spec which defines an additional property nullable: bool
Example of nullable int in OpenAPI:
{
"type": "integer",
"nullable": true
}
from saunter.
This is implemented using a [Flags] enum
in Newtonsoft.Json.Schema
https://github.com/JamesNK/Newtonsoft.Json.Schema/blob/master/Src/Newtonsoft.Json.Schema/JSchemaType.cs
Same as NJsonSchema
https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/JsonObjectType.cs
I suppose this is the easiest way to be able to set this as one or more value.
// for non-nullable primitives
Type = JsonSchemaType.Integer;
// for nullable-primitives
Type = JsonSchemaType.Integer | JsonSchemaType.Null;
This also allows for setting the nullable type separate from the underlying type;
var type = JsonObjectType.Integer;
//... elsewhere
if (nullable) {
type = type | JsonObjectType.Null;
}
from saunter.
Closing in favor of #60
from saunter.
Related Issues (20)
- [FEATURE] update logo and project URLs
- [FEATURE] Support AOT Trimmed applications HOT 3
- [FEATURE] Migrate to DTO from AsyncApi.Net HOT 7
- Operation types in the side panel index are not correct HOT 1
- Rename & change namespace of project
- Allows greater flexibility in serializer to be used HOT 1
- Allows greater flexibility in bindings to be used HOT 1
- Add in the ability to generate ASYNCAPI Yaml HOT 2
- Publish a global dotnet tool HOT 2
- Produce AsyncAPI documents at build time HOT 2
- Only generate schema on initial request HOT 2
- Produce a standalone Attribute Package
- Implement more dotnet best practises HOT 2
- Add an editorconfig to the project
- Dotnet cli tool can scaffold files
- [📑 Docs]: We need a roadmap!! HOT 3
- [FEATURE] Generate classes based on AsyncAPI document HOT 4
- [FEATURE] Check fmt + test on CI
- [FEATURE] Migrate to target arch HOT 2
- [FEATURE] Allow usages of the annotation attributes on interfaces (not only classes)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saunter.