public static void Main(string[] args) { try { string resourceName = typeof(Program).Namespace + ".Properties.openapi.json"; OpenApiDocument openapi = LoadApiSpecification(resourceName); EntitiesGenerator.GenerateEntities(openapi, true); ClientGenerator.GenerateClient(openapi, true); } catch (Exception exception) { Console.Error.WriteLine(exception.Message + Environment.NewLine + exception.StackTrace); } }
public static MethodBuilder GenerateMethod(OpenApiDocument document, OpenApiOperation method, bool isPost, string path, string area, string name, string description) { if (!path.StartsWith("/")) { throw new ArgumentException("Path must start and end with a slash.", nameof(path)); } bool includeTrailingSlash = path.EndsWith("/"); TypeReference returnType = GrokReturnType(document, method.Responses["200"]); List <ParameterBuilder> parameterBuilders = ( from jsonParameter in method.Parameters select new ParameterBuilder() { JsonName = jsonParameter.Name, Name = jsonParameter.Name, Location = (BuilderParameterLocation?)jsonParameter.In ?? throw new Exception("Null argument location."), Description = jsonParameter.Description, Type = EntitiesGenerator.ProcessPropertyType(jsonParameter.Schema), }).ToList();