简体   繁体   中英

Generate swagger v2 schema by NJsonSchema for .NET or Newtonsoft.Json.Schema

I need to use a tool, preferably NJsonSchema for .NET to generate schemas from c# classes. The requirement is to create schemas based on swagger version 2. For example I cannot have oneOf, anyOf, etc, which are new keywords in OAS3 in the schema. Can we specify the swagger/OAS version in the schema generator? How can this be done?

I just found that there is a setting in NJsonSchema for choosing the version:

var settings = new JsonSchemaGeneratorSettings
            {
                SchemaType = NJsonSchema.SchemaType.Swagger2,
            };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM