From 935831003d2dd4151cc16434aa325831b6ddf451 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Tue, 31 Oct 2017 16:50:29 -0700 Subject: [PATCH 01/13] basic parsing --- src/BuilderExtensions.cs | 28 +++++++++++++++ src/Model/Operation.cs | 14 +++----- src/Model/Response.cs | 11 +++++- src/Model/ServiceDefinition.cs | 64 +++++++++++++++++----------------- src/ObjectBuilder.cs | 4 +-- src/OperationBuilder.cs | 4 +-- src/ParameterBuilder.cs | 2 +- src/SchemaBuilder.cs | 6 ++-- src/SchemaResolver.cs | 8 ++--- src/SwaggerModeler.cs | 31 ++++++++-------- 10 files changed, 102 insertions(+), 70 deletions(-) diff --git a/src/BuilderExtensions.cs b/src/BuilderExtensions.cs index dada2ac..4f9ee92 100644 --- a/src/BuilderExtensions.cs +++ b/src/BuilderExtensions.cs @@ -16,6 +16,34 @@ namespace AutoRest.Modeler { public static class BuilderExtensions { + /// + /// Removes #/components/parameters/ or url#/components/parameters from the reference path. + /// + public static string StripComponentsParameterPath(this string reference) + { + if (reference != null && reference.Contains("#/components/parameters/")) + { + reference = reference.Substring(reference.IndexOf("#/components/parameters/", StringComparison.OrdinalIgnoreCase) + + "#/components/parameters/".Length); + } + + return reference; + } + + /// + /// Removes #/components/schemas/ or url#/components/schemas from the reference path. + /// + public static string StripComponentsSchemaPath(this string reference) + { + if (reference != null && reference.Contains("#/components/schemas/")) + { + reference = reference.Substring(reference.IndexOf("#/components/schemas/", StringComparison.OrdinalIgnoreCase) + + "#/components/schemas/".Length); + } + + return reference; + } + /// /// A schema represents a primitive type if it's not an object or it represents a dictionary /// diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index 3732766..055c30c 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -17,8 +17,6 @@ public class Operation : SwaggerBase public Operation() { - Consumes = new List(); - Produces = new List(); } /// @@ -50,15 +48,11 @@ public string Description /// public ExternalDoc ExternalDocs { get; set; } - /// - /// A list of MIME types the operation can consume. - /// - public IList Consumes { get; set; } + // TODO: fix/remove + public IList Consumes => new List { "application/json" }; - /// - /// A list of MIME types the operation can produce. - /// - public IList Produces { get; set; } + // TODO: fix/remove + public IList Produces => new List { "application/json" }; /// /// A list of parameters that are applicable for this operation. diff --git a/src/Model/Response.cs b/src/Model/Response.cs index 3197a24..ff4eb50 100644 --- a/src/Model/Response.cs +++ b/src/Model/Response.cs @@ -4,6 +4,7 @@ using AutoRest.Core.Utilities; using System; using System.Collections.Generic; +using System.Linq; namespace AutoRest.Modeler.Model { @@ -20,10 +21,18 @@ public string Description set { _description = value.StripControlCharacters(); } } - public Schema Schema { get; set; } + // TODO: get rid of this + public Schema Schema => Content?.Values.FirstOrDefault()?.Schema; + + public Dictionary Content { get; set; } public Dictionary Headers { get; set; } public Dictionary Examples { get; set; } } + + public class MediaTypeObject : SwaggerBase + { + public Schema Schema { get; set; } + } } \ No newline at end of file diff --git a/src/Model/ServiceDefinition.cs b/src/Model/ServiceDefinition.cs index e796575..4af53b7 100644 --- a/src/Model/ServiceDefinition.cs +++ b/src/Model/ServiceDefinition.cs @@ -16,23 +16,19 @@ public class ServiceDefinition : SpecObject { public ServiceDefinition() { - Definitions = new Dictionary(); + Components = new Components(); Schemes = new List(); - Consumes = new List(); - Produces = new List(); Paths = new Dictionary>(); CustomPaths = new Dictionary>(); - Parameters = new Dictionary(); - Responses = new Dictionary(); SecurityDefinitions = new Dictionary(); Security = new List>>(); Tags = new List(); } /// - /// Specifies the Swagger Specification version being used. + /// Specifies the OpenApi Specification version being used. /// - public string Swagger { get; set; } + public string OpenApi { get; set; } /// /// Provides metadata about the API. The metadata can be used by the clients if needed. @@ -54,15 +50,11 @@ public ServiceDefinition() /// public IList Schemes { get; set; } - /// - /// A list of MIME types the service can consume. - /// - public IList Consumes { get; set; } + // TODO: remove + public IList Consumes => new List(); - /// - /// A list of MIME types the APIs can produce. - /// - public IList Produces { get; set; } + // TODO: remove + public IList Produces => new List(); /// /// Key is actual path and the value is serializationProperty of http operations and operation objects. @@ -75,21 +67,7 @@ public ServiceDefinition() [JsonProperty("x-ms-paths")] public Dictionary> CustomPaths { get; set; } - /// - /// Key is the object serviceTypeName and the value is swagger definition. - /// - public Dictionary Definitions { get; set; } - - /// - /// Dictionary of parameters that can be used across operations. - /// This property does not define global parameters for all operations. - /// - public Dictionary Parameters { get; set; } - - /// - /// Dictionary of responses that can be used across operations. The key indicates status code. - /// - public Dictionary Responses { get; set; } + public Components Components { get; set; } /// /// Key is the object serviceTypeName and the value is swagger security definition. @@ -117,10 +95,32 @@ public ServiceDefinition() /// Additional external documentation /// public ExternalDoc ExternalDocs { get; set; } + } + + public class Components + { + public Components() + { + Schemas = new Dictionary(); + Parameters = new Dictionary(); + Responses = new Dictionary(); + } + + /// + /// Key is the object serviceTypeName and the value is swagger definition. + /// + public Dictionary Schemas { get; set; } + + /// + /// Dictionary of parameters that can be used across operations. + /// This property does not define global parameters for all operations. + /// + public Dictionary Parameters { get; set; } /// - /// Path to this Swagger. + /// Dictionary of responses that can be used across operations. The key indicates status code. /// - internal Uri FilePath { get; set; } + public Dictionary Responses { get; set; } + } } \ No newline at end of file diff --git a/src/ObjectBuilder.cs b/src/ObjectBuilder.cs index db5df0b..b100068 100644 --- a/src/ObjectBuilder.cs +++ b/src/ObjectBuilder.cs @@ -151,7 +151,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) string itemServiceTypeName; if (SwaggerObject.Items.Reference != null) { - itemServiceTypeName = SwaggerObject.Items.Reference.StripDefinitionPath(); + itemServiceTypeName = SwaggerObject.Items.Reference.StripComponentsSchemaPath(); } else { @@ -173,7 +173,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) string dictionaryValueServiceTypeName; if (SwaggerObject.AdditionalProperties.Reference != null) { - dictionaryValueServiceTypeName = SwaggerObject.AdditionalProperties.Reference.StripDefinitionPath(); + dictionaryValueServiceTypeName = SwaggerObject.AdditionalProperties.Reference.StripComponentsSchemaPath(); } else { diff --git a/src/OperationBuilder.cs b/src/OperationBuilder.cs index 53b3f5f..3b0cf4f 100644 --- a/src/OperationBuilder.cs +++ b/src/OperationBuilder.cs @@ -369,7 +369,7 @@ private bool TryBuildStreamResponse(HttpStatusCode responseStatusCode, Operation if (response.Schema != null) { IModelType serviceType = response.Schema.GetBuilder(_swaggerModeler) - .BuildServiceType(response.Schema.Reference.StripDefinitionPath()); + .BuildServiceType(response.Schema.Reference.StripComponentsSchemaPath()); Debug.Assert(serviceType != null); @@ -474,7 +474,7 @@ private bool TryBuildResponseBody(string methodName, OperationResponse response, string referenceKey; if (response.Schema.Reference != null) { - referenceKey = response.Schema.Reference.StripDefinitionPath(); + referenceKey = response.Schema.Reference.StripComponentsSchemaPath(); response.Schema.Reference = referenceKey; } else diff --git a/src/ParameterBuilder.cs b/src/ParameterBuilder.cs index 7076269..9eb864c 100644 --- a/src/ParameterBuilder.cs +++ b/src/ParameterBuilder.cs @@ -37,7 +37,7 @@ public Parameter Build() if (unwrappedParameter.Schema != null && unwrappedParameter.Schema.Reference != null) { - parameterName = unwrappedParameter.Schema.Reference.StripDefinitionPath(); + parameterName = unwrappedParameter.Schema.Reference.StripComponentsSchemaPath(); } if (parameterName == null) diff --git a/src/SchemaBuilder.cs b/src/SchemaBuilder.cs index 85e3e8b..e145db6 100644 --- a/src/SchemaBuilder.cs +++ b/src/SchemaBuilder.cs @@ -76,7 +76,7 @@ public override IModelType BuildServiceType(string serviceTypeName) { ValueType = _schema.AdditionalProperties.GetBuilder(Modeler).BuildServiceType( _schema.AdditionalProperties.Reference != null - ? _schema.AdditionalProperties.Reference.StripDefinitionPath() + ? _schema.AdditionalProperties.Reference.StripComponentsSchemaPath() : serviceTypeName + "Value"), Extensions = _schema.AdditionalProperties.Extensions, SupportsAdditionalProperties = true @@ -112,7 +112,7 @@ public override IModelType BuildServiceType(string serviceTypeName) if (property.Value.Reference != null) { - propertyServiceTypeName = property.Value.Reference.StripDefinitionPath(); + propertyServiceTypeName = property.Value.Reference.StripComponentsSchemaPath(); var unwrappedSchema = Modeler.Resolver.Unwrap(property.Value); // For Enums use the referenced schema in order to set the correct property Type and Enum values @@ -182,7 +182,7 @@ public override IModelType BuildServiceType(string serviceTypeName) if (_schema.Extends != null) { // Put this in the extended type serializationProperty for building method return type in the end - Modeler.ExtendedTypes[serviceTypeName] = _schema.Extends.StripDefinitionPath(); + Modeler.ExtendedTypes[serviceTypeName] = _schema.Extends.StripComponentsSchemaPath(); } // Put this in already generated types serializationProperty diff --git a/src/SchemaResolver.cs b/src/SchemaResolver.cs index a8e49ac..1ab67f7 100644 --- a/src/SchemaResolver.cs +++ b/src/SchemaResolver.cs @@ -344,15 +344,15 @@ private Schema DereferenceInner(string referencePath, List visitedRefere throw new ArgumentException(Properties.Resources.ExceededMaximumReferenceDepth, referencePath); } visitedReferences.Add(referencePath.ToUpperInvariant()); - var definitions = _serviceDefinition.Definitions; - if (definitions == null || !definitions.ContainsKey(referencePath.StripDefinitionPath())) + var definitions = _serviceDefinition.Components.Schemas; + if (definitions == null || !definitions.ContainsKey(referencePath.StripComponentsSchemaPath())) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ReferenceDoesNotExist, - referencePath.StripDefinitionPath())); + referencePath.StripComponentsSchemaPath())); } - var schema = _serviceDefinition.Definitions[referencePath.StripDefinitionPath()]; + var schema = definitions[referencePath.StripComponentsSchemaPath()]; if (schema.Reference != null) { schema = DereferenceInner(schema.Reference, visitedReferences); diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index 8c04030..a8dbd8a 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -69,7 +69,7 @@ public CodeModel Build(ServiceDefinition serviceDefinition) BuildCompositeTypes(); // Build client parameters - foreach (var swaggerParameter in ServiceDefinition.Parameters.Values) + foreach (var swaggerParameter in ServiceDefinition.Components.Parameters.Values) { var parameter = ((ParameterBuilder)swaggerParameter.GetBuilder(this)).Build(); @@ -168,7 +168,7 @@ private void UpdateSettings() /// The base ServiceModel Service private void InitializeClientModel() { - if (string.IsNullOrEmpty(ServiceDefinition.Swagger)) + if (string.IsNullOrEmpty(ServiceDefinition.OpenApi)) { throw ErrorManager.CreateError(Resources.UnknownSwaggerVersion); } @@ -291,18 +291,19 @@ private void ProcessParameterizedHost() /// public virtual void BuildCompositeTypes() { + var schemas = ServiceDefinition.Components.Schemas; // Build service types and validate allOf - if (ServiceDefinition.Definitions != null) + if (schemas != null) { - foreach (var schemaName in ServiceDefinition.Definitions.Keys.ToArray()) + foreach (var schemaName in schemas.Keys.ToArray()) { - var schema = ServiceDefinition.Definitions[schemaName]; + var schema = schemas[schemaName]; schema.GetBuilder(this).BuildServiceType(schemaName); Resolver.ExpandAllOf(schema); - var parent = string.IsNullOrEmpty(schema.Extends.StripDefinitionPath()) + var parent = string.IsNullOrEmpty(schema.Extends.StripComponentsSchemaPath()) ? null - : ServiceDefinition.Definitions[schema.Extends.StripDefinitionPath()]; + : schemas[schema.Extends.StripComponentsSchemaPath()]; if (parent != null && !AncestorsHaveProperties(parent.Properties, parent.Extends) && @@ -332,11 +333,12 @@ private bool AncestorsHaveProperties(Dictionary properties, stri { return true; } + var schemas = ServiceDefinition.Components.Schemas; - extends = extends.StripDefinitionPath(); - Debug.Assert(!string.IsNullOrEmpty(extends) && ServiceDefinition.Definitions.ContainsKey(extends)); - return AncestorsHaveProperties(ServiceDefinition.Definitions[extends].Properties, - ServiceDefinition.Definitions[extends].Extends); + extends = extends.StripComponentsSchemaPath(); + Debug.Assert(!string.IsNullOrEmpty(extends) && schemas.ContainsKey(extends)); + return AncestorsHaveProperties(schemas[extends].Properties, + schemas[extends].Extends); } /// @@ -394,7 +396,6 @@ public static string GetMethodName(Operation operation) public static string GetMethodNameFromOperationId(string operationId) => (operationId?.IndexOf('_') != -1) ? operationId.Split('_').Last(): operationId; - public SwaggerParameter Unwrap(SwaggerParameter swaggerParameter) { @@ -406,15 +407,15 @@ public SwaggerParameter Unwrap(SwaggerParameter swaggerParameter) // If referencing global parameters serializationProperty if (swaggerParameter.Reference != null) { - string referenceKey = swaggerParameter.Reference.StripParameterPath(); - if (!ServiceDefinition.Parameters.ContainsKey(referenceKey)) + string referenceKey = swaggerParameter.Reference.StripComponentsParameterPath(); + if (!ServiceDefinition.Components.Parameters.ContainsKey(referenceKey)) { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, Resources.DefinitionDoesNotExist, referenceKey)); } - swaggerParameter = ServiceDefinition.Parameters[referenceKey]; + swaggerParameter = ServiceDefinition.Components.Parameters[referenceKey]; } // Unwrap the schema if in "body" From 6a4c54aea5c755f9a86d9d3ca230287e495e5714 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Wed, 1 Nov 2017 11:19:48 -0700 Subject: [PATCH 02/13] pre param gutting --- src/Model/MediaTypeObject.cs | 11 ++++++++++ src/Model/Operation.cs | 17 ++++++++++++++- src/Model/RequestBody.cs | 39 ++++++++++++++++++++++++++++++++++ src/Model/Response.cs | 5 ----- src/Model/ServiceDefinition.cs | 14 +++++++----- src/Model/SwaggerObject.cs | 2 +- src/Model/SwaggerParameter.cs | 6 +++--- src/SwaggerModeler.cs | 4 +--- src/SwaggerParser.cs | 10 +++++++-- 9 files changed, 88 insertions(+), 20 deletions(-) create mode 100644 src/Model/MediaTypeObject.cs create mode 100644 src/Model/RequestBody.cs diff --git a/src/Model/MediaTypeObject.cs b/src/Model/MediaTypeObject.cs new file mode 100644 index 0000000..1c451a3 --- /dev/null +++ b/src/Model/MediaTypeObject.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + + +namespace AutoRest.Modeler.Model +{ + public class MediaTypeObject : SwaggerBase + { + public Schema Schema { get; set; } + } +} \ No newline at end of file diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index 055c30c..e795f72 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -54,12 +54,27 @@ public string Description // TODO: fix/remove public IList Produces => new List { "application/json" }; + IList _parameters; /// /// A list of parameters that are applicable for this operation. /// If a parameter is already defined at the Path Item, the /// new definition will override it, but can never remove it. /// - public IList Parameters { get; set; } + public IList Parameters + { + get + { + var result = _parameters?.ToList(); + if (RequestBody != null && result != null) + { + result.Insert(RequestBody.Index, RequestBody.AsParameter()); + } + return result; + } + set => _parameters = value.Where(v => v.In != ParameterLocation.Body).ToList(); + } // TODO: not like this... + + public RequestBody RequestBody { get; set; } /// /// The list of possible responses as they are returned from executing this operation. diff --git a/src/Model/RequestBody.cs b/src/Model/RequestBody.cs new file mode 100644 index 0000000..68665b9 --- /dev/null +++ b/src/Model/RequestBody.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using AutoRest.Core.Utilities; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace AutoRest.Modeler.Model +{ + /// + /// Describes a single response from an API Operation. + /// + public class RequestBody : SwaggerBase + { + private string _description; + + public string Description + { + get { return _description; } + set { _description = value.StripControlCharacters(); } + } + + // TODO: get rid of this + public SwaggerParameter AsParameter() => new SwaggerParameter + { + Description = Description, + In = ParameterLocation.Body, + Name = "body", // TODO + IsRequired = Required, + Schema = Content?.Values.FirstOrDefault()?.Schema + }; + public int Index => 0; // TODO + + public Dictionary Content { get; set; } + + public bool Required { get; set; } + } +} \ No newline at end of file diff --git a/src/Model/Response.cs b/src/Model/Response.cs index ff4eb50..8ae71d6 100644 --- a/src/Model/Response.cs +++ b/src/Model/Response.cs @@ -30,9 +30,4 @@ public string Description public Dictionary Examples { get; set; } } - - public class MediaTypeObject : SwaggerBase - { - public Schema Schema { get; set; } - } } \ No newline at end of file diff --git a/src/Model/ServiceDefinition.cs b/src/Model/ServiceDefinition.cs index 4af53b7..97c63d8 100644 --- a/src/Model/ServiceDefinition.cs +++ b/src/Model/ServiceDefinition.cs @@ -35,10 +35,7 @@ public ServiceDefinition() /// public Info Info { get; set; } - /// - /// The host (serviceTypeName or ip) serving the API. - /// - public string Host { get; set; } + public IList Servers { get; set; } /// /// The base path on which the API is served, which is relative to the host. @@ -97,7 +94,14 @@ public ServiceDefinition() public ExternalDoc ExternalDocs { get; set; } } - public class Components + public class Server : SwaggerBase + { + public string Url { get; set; } + public string Description { get; set; } + public Dictionary Variables { get; set; } + } + + public class Components : SwaggerBase { public Components() { diff --git a/src/Model/SwaggerObject.cs b/src/Model/SwaggerObject.cs index 184aeb6..bef81ff 100644 --- a/src/Model/SwaggerObject.cs +++ b/src/Model/SwaggerObject.cs @@ -120,7 +120,7 @@ public ObjectBuilder GetBuilder(SwaggerModeler swaggerSpecBuilder) /// public PrimaryType ToType() { - switch (Type) + switch (Type ?? (this as SwaggerParameter)?.Schema?.Type) { case DataType.String: switch (KnownFormat) diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index b9b01a4..94c7b3f 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -9,7 +9,7 @@ namespace AutoRest.Modeler.Model /// Describes a single operation parameter. /// https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#parameterObject /// - public class SwaggerParameter : SwaggerObject + public class SwaggerParameter : SwaggerBase { private bool _isRequired; public string Name { get; set; } @@ -17,14 +17,14 @@ public class SwaggerParameter : SwaggerObject public ParameterLocation In { get; set; } [JsonProperty(PropertyName = "required")] - public override bool IsRequired + public bool IsRequired { get { return (_isRequired) || In == ParameterLocation.Path; } set { _isRequired = value; } } [JsonIgnore] - public bool IsConstant => IsRequired && Enum != null && Enum.Count == 1; + public bool IsConstant => IsRequired && Schema?.Enum != null && Schema?.Enum.Count == 1; /// /// The schema defining the type used for the body parameter. diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index a8dbd8a..43fe554 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -191,9 +191,7 @@ private void InitializeClientModel() CodeModel.ModelsName = settings.ModelsName; CodeModel.ApiVersion = ServiceDefinition.Info.Version; CodeModel.Documentation = ServiceDefinition.Info.Description; - CodeModel.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}", - ServiceDefinition.Schemes[0].ToString().ToLower(), - ServiceDefinition.Host, ServiceDefinition.BasePath); + CodeModel.BaseUrl = ServiceDefinition.Servers[0].Url.TrimEnd('/'); // Copy extensions ServiceDefinition.Info?.CodeGenerationSettings?.Extensions.ForEach(extention => CodeModel.CodeGenExtensions.AddOrSet(extention.Key, extention.Value)); diff --git a/src/SwaggerParser.cs b/src/SwaggerParser.cs index 8ed23c3..fe2d526 100644 --- a/src/SwaggerParser.cs +++ b/src/SwaggerParser.cs @@ -49,9 +49,15 @@ public static ServiceDefinition Parse(string swaggerDocument) { swaggerService.Schemes = new List { TransferProtocolScheme.Http }; } - if (string.IsNullOrEmpty(swaggerService.Host)) + if (swaggerService.Servers == null || swaggerService.Servers.Count == 0) { - swaggerService.Host = "localhost"; + swaggerService.Servers = new List + { + new Server + { + Url = "/" + } + }; } return swaggerService; } From fc7fb9cb098168b5f99c181e304ffe1f296be9d6 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Wed, 1 Nov 2017 13:36:57 -0700 Subject: [PATCH 03/13] more translation --- src/BuilderExtensions.cs | 27 ++++++++----------------- src/CollectionFormatBuilder.cs | 6 +++--- src/Model/Components.cs | 36 ++++++++++++++++++++++++++++++++++ src/Model/RequestBody.cs | 11 ++++++++--- src/Model/Schema.cs | 2 ++ src/Model/Server.cs | 14 +++++++++++++ src/Model/ServiceDefinition.cs | 34 -------------------------------- src/Model/SwaggerBase.cs | 13 ++++++++++++ src/Model/SwaggerObject.cs | 15 +------------- src/Model/SwaggerParameter.cs | 5 +++++ src/ObjectBuilder.cs | 28 ++++++++++++++++++++++++++ src/OperationBuilder.cs | 6 ++---- src/ParameterBuilder.cs | 2 +- src/SchemaBuilder.cs | 6 ++++++ src/SwaggerModeler.cs | 31 ++++++++++++++++++++++------- 15 files changed, 151 insertions(+), 85 deletions(-) create mode 100644 src/Model/Components.cs create mode 100644 src/Model/Server.cs diff --git a/src/BuilderExtensions.cs b/src/BuilderExtensions.cs index 4f9ee92..99de160 100644 --- a/src/BuilderExtensions.cs +++ b/src/BuilderExtensions.cs @@ -17,32 +17,21 @@ namespace AutoRest.Modeler public static class BuilderExtensions { /// - /// Removes #/components/parameters/ or url#/components/parameters from the reference path. + /// Removes #/components/{component}/ or url#/components/{component} from the reference path. /// - public static string StripComponentsParameterPath(this string reference) + private static string StripSomeComponentPath(string component, string reference) { - if (reference != null && reference.Contains("#/components/parameters/")) + var prefix = $"#/components/{component}/"; + if (reference != null && reference.Contains(prefix)) { - reference = reference.Substring(reference.IndexOf("#/components/parameters/", StringComparison.OrdinalIgnoreCase) + - "#/components/parameters/".Length); + reference = reference.Substring(reference.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length); } - return reference; } - /// - /// Removes #/components/schemas/ or url#/components/schemas from the reference path. - /// - public static string StripComponentsSchemaPath(this string reference) - { - if (reference != null && reference.Contains("#/components/schemas/")) - { - reference = reference.Substring(reference.IndexOf("#/components/schemas/", StringComparison.OrdinalIgnoreCase) + - "#/components/schemas/".Length); - } - - return reference; - } + public static string StripComponentsParameterPath(this string reference) => StripSomeComponentPath("parameters", reference); + public static string StripComponentsRequestBodyPath(this string reference) => StripSomeComponentPath("requestBodies", reference); + public static string StripComponentsSchemaPath(this string reference) => StripSomeComponentPath("schemas", reference); /// /// A schema represents a primitive type if it's not an object or it represents a dictionary diff --git a/src/CollectionFormatBuilder.cs b/src/CollectionFormatBuilder.cs index 2ba4622..90df2f9 100644 --- a/src/CollectionFormatBuilder.cs +++ b/src/CollectionFormatBuilder.cs @@ -23,12 +23,12 @@ public static StringBuilder OnBuildMethodParameter(Method method, throw new ArgumentNullException("currentSwaggerParam"); } - bool hasCollectionFormat = currentSwaggerParam.CollectionFormat != CollectionFormat.None; + bool hasCollectionFormat = currentSwaggerParam.Schema?.CollectionFormat != CollectionFormat.None; - if (currentSwaggerParam.Type == DataType.Array && !hasCollectionFormat) + if (currentSwaggerParam.Schema?.Type == DataType.Array && !hasCollectionFormat) { // If the parameter type is array default the collectionFormat to csv - currentSwaggerParam.CollectionFormat = CollectionFormat.Csv; + currentSwaggerParam.Schema.CollectionFormat = CollectionFormat.Csv; } if (hasCollectionFormat) diff --git a/src/Model/Components.cs b/src/Model/Components.cs new file mode 100644 index 0000000..493f69c --- /dev/null +++ b/src/Model/Components.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Collections.Generic; + +namespace AutoRest.Modeler.Model +{ + public class Components : SwaggerBase + { + public Components() + { + Schemas = new Dictionary(); + Parameters = new Dictionary(); + Responses = new Dictionary(); + } + + /// + /// Key is the object serviceTypeName and the value is swagger definition. + /// + public Dictionary Schemas { get; set; } + + /// + /// Dictionary of parameters that can be used across operations. + /// This property does not define global parameters for all operations. + /// + public Dictionary Parameters { get; set; } + + public Dictionary RequestBodies { get; set; } + + /// + /// Dictionary of responses that can be used across operations. The key indicates status code. + /// + public Dictionary Responses { get; set; } + + } +} \ No newline at end of file diff --git a/src/Model/RequestBody.cs b/src/Model/RequestBody.cs index 68665b9..3ca03b8 100644 --- a/src/Model/RequestBody.cs +++ b/src/Model/RequestBody.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Newtonsoft.Json; namespace AutoRest.Modeler.Model { @@ -21,16 +22,20 @@ public string Description set { _description = value.StripControlCharacters(); } } + [JsonProperty(PropertyName = "$ref")] + public string Reference { get; set; } + // TODO: get rid of this public SwaggerParameter AsParameter() => new SwaggerParameter { Description = Description, In = ParameterLocation.Body, - Name = "body", // TODO + Name = Extensions.GetValue("x-ms-client-name") ?? "body", IsRequired = Required, - Schema = Content?.Values.FirstOrDefault()?.Schema + Schema = Content?.Values.FirstOrDefault()?.Schema, + Reference = Reference }; - public int Index => 0; // TODO + public int Index => Extensions.Get("x-ms-requestBody-index") ?? 0; public Dictionary Content { get; set; } diff --git a/src/Model/Schema.cs b/src/Model/Schema.cs index a4152cb..dc42fb0 100644 --- a/src/Model/Schema.cs +++ b/src/Model/Schema.cs @@ -24,6 +24,8 @@ public class Schema : SwaggerObject /// public string Discriminator { get; set; } + public bool? Nullable { get; set; } + /// /// Key is a type serviceTypeName. /// diff --git a/src/Model/Server.cs b/src/Model/Server.cs new file mode 100644 index 0000000..20f0006 --- /dev/null +++ b/src/Model/Server.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Collections.Generic; + +namespace AutoRest.Modeler.Model +{ + public class Server : SwaggerBase + { + public string Url { get; set; } + public string Description { get; set; } + public Dictionary Variables { get; set; } + } +} \ No newline at end of file diff --git a/src/Model/ServiceDefinition.cs b/src/Model/ServiceDefinition.cs index 97c63d8..0f0149c 100644 --- a/src/Model/ServiceDefinition.cs +++ b/src/Model/ServiceDefinition.cs @@ -93,38 +93,4 @@ public ServiceDefinition() /// public ExternalDoc ExternalDocs { get; set; } } - - public class Server : SwaggerBase - { - public string Url { get; set; } - public string Description { get; set; } - public Dictionary Variables { get; set; } - } - - public class Components : SwaggerBase - { - public Components() - { - Schemas = new Dictionary(); - Parameters = new Dictionary(); - Responses = new Dictionary(); - } - - /// - /// Key is the object serviceTypeName and the value is swagger definition. - /// - public Dictionary Schemas { get; set; } - - /// - /// Dictionary of parameters that can be used across operations. - /// This property does not define global parameters for all operations. - /// - public Dictionary Parameters { get; set; } - - /// - /// Dictionary of responses that can be used across operations. The key indicates status code. - /// - public Dictionary Responses { get; set; } - - } } \ No newline at end of file diff --git a/src/Model/SwaggerBase.cs b/src/Model/SwaggerBase.cs index eaa26a3..09cef66 100644 --- a/src/Model/SwaggerBase.cs +++ b/src/Model/SwaggerBase.cs @@ -18,5 +18,18 @@ public SwaggerBase() /// [JsonExtensionData] public Dictionary Extensions { get; set; } + + public ObjectBuilder GetBuilder(SwaggerModeler swaggerSpecBuilder) + { + if (this is SwaggerParameter) + { + return new ParameterBuilder(this as SwaggerParameter, swaggerSpecBuilder); + } + if (this is Schema) + { + return new SchemaBuilder(this as Schema, swaggerSpecBuilder); + } + return new ObjectBuilder(this as SwaggerObject, swaggerSpecBuilder); + } } } \ No newline at end of file diff --git a/src/Model/SwaggerObject.cs b/src/Model/SwaggerObject.cs index bef81ff..8a7a5ea 100644 --- a/src/Model/SwaggerObject.cs +++ b/src/Model/SwaggerObject.cs @@ -90,19 +90,6 @@ public virtual string Description public virtual IList Enum { get; set; } - public ObjectBuilder GetBuilder(SwaggerModeler swaggerSpecBuilder) - { - if (this is SwaggerParameter) - { - return new ParameterBuilder(this as SwaggerParameter, swaggerSpecBuilder); - } - if (this is Schema) - { - return new SchemaBuilder(this as Schema, swaggerSpecBuilder); - } - return new ObjectBuilder(this, swaggerSpecBuilder); - } - /// /// Returns the PrimaryType that the SwaggerObject maps to, given the Type and the KnownFormat. /// @@ -120,7 +107,7 @@ public ObjectBuilder GetBuilder(SwaggerModeler swaggerSpecBuilder) /// public PrimaryType ToType() { - switch (Type ?? (this as SwaggerParameter)?.Schema?.Type) + switch (Type) { case DataType.String: switch (KnownFormat) diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index 94c7b3f..fe9e3a9 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -14,6 +14,11 @@ public class SwaggerParameter : SwaggerBase private bool _isRequired; public string Name { get; set; } + public string Description { get; set; } + + [JsonProperty(PropertyName = "$ref")] + public string Reference { get; set; } + public ParameterLocation In { get; set; } [JsonProperty(PropertyName = "required")] diff --git a/src/ObjectBuilder.cs b/src/ObjectBuilder.cs index b100068..c36d26e 100644 --- a/src/ObjectBuilder.cs +++ b/src/ObjectBuilder.cs @@ -220,6 +220,34 @@ public static void PopulateParameter(IVariable parameter, SwaggerObject swaggerO SetConstraints(parameter.Constraints, swaggerObject); } + public static void PopulateParameter(IVariable parameter, SwaggerParameter swaggerObject) + { + if (swaggerObject == null) + { + throw new ArgumentNullException("swaggerObject"); + } + if (parameter == null) + { + throw new ArgumentNullException("parameter"); + } + parameter.IsRequired = swaggerObject.IsRequired; + parameter.DefaultValue = swaggerObject.Schema?.Default; + + if (IsSwaggerObjectConstant(swaggerObject.Schema)) + { + parameter.DefaultValue = swaggerObject.Schema.Enum[0]; + parameter.IsConstant = true; + } + + parameter.Documentation = swaggerObject.Description; + parameter.CollectionFormat = swaggerObject.Schema.CollectionFormat; + + // tag the paramter with all the extensions from the swagger object + parameter.Extensions.AddRange(swaggerObject.Extensions); + + SetConstraints(parameter.Constraints, swaggerObject.Schema); + } + private static bool IsSwaggerObjectConstant(SwaggerObject swaggerObject) { return (swaggerObject.Enum != null && swaggerObject.Enum.Count == 1 && swaggerObject.IsRequired); diff --git a/src/OperationBuilder.cs b/src/OperationBuilder.cs index 3b0cf4f..ed1288e 100644 --- a/src/OperationBuilder.cs +++ b/src/OperationBuilder.cs @@ -244,18 +244,16 @@ private void BuildMethodParameters(Method method) continue; // ignore these case "Content-Type": // special treatment for data-plane // enrich Content-Type header with "consumes" - if (actualSwaggerParameter.Enum == null && + if (actualSwaggerParameter.Schema.Enum == null && _effectiveConsumes.Count > 1) { - swaggerParameter.Default = actualSwaggerParameter.Default; swaggerParameter.Description = actualSwaggerParameter.Description; swaggerParameter.Extensions = actualSwaggerParameter.Extensions; swaggerParameter.In = actualSwaggerParameter.In; swaggerParameter.IsRequired = actualSwaggerParameter.IsRequired; swaggerParameter.Name = actualSwaggerParameter.Name; swaggerParameter.Schema = actualSwaggerParameter.Schema; - swaggerParameter.Type = actualSwaggerParameter.Type; - swaggerParameter.Enum = _effectiveConsumes.ToList(); + swaggerParameter.Schema.Enum = _effectiveConsumes.ToList(); // if not treated explicitly, add choices to the global choices if (swaggerParameter.Extensions.GetValue("x-ms-enum") == null) { diff --git a/src/ParameterBuilder.cs b/src/ParameterBuilder.cs index 9eb864c..49da289 100644 --- a/src/ParameterBuilder.cs +++ b/src/ParameterBuilder.cs @@ -20,7 +20,7 @@ public class ParameterBuilder : ObjectBuilder private readonly SwaggerParameter _swaggerParameter; public ParameterBuilder(SwaggerParameter swaggerParameter, SwaggerModeler modeler) - : base(swaggerParameter, modeler) + : base(swaggerParameter.Schema, modeler) { _swaggerParameter = swaggerParameter; } diff --git a/src/SchemaBuilder.cs b/src/SchemaBuilder.cs index e145db6..f00a599 100644 --- a/src/SchemaBuilder.cs +++ b/src/SchemaBuilder.cs @@ -34,6 +34,12 @@ public override IModelType BuildServiceType(string serviceTypeName) { _schema = Modeler.Resolver.Unwrap(_schema); + // translate nullable back to what "code-model-v1"-gen generators expect + if (_schema.Nullable.HasValue && !_schema.Extensions.ContainsKey("x-nullable")) + { + _schema.Extensions["x-nullable"] = _schema.Nullable.Value; + } + // If it's a primitive type, let the parent build service handle it if (_schema.IsPrimitiveType()) { diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index 43fe554..01b74cd 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -189,7 +189,9 @@ private void InitializeClientModel() CodeModel.Namespace = settings.Namespace; CodeModel.ModelsName = settings.ModelsName; - CodeModel.ApiVersion = ServiceDefinition.Info.Version; + CodeModel.ApiVersion = ServiceDefinition.Info.Version == "" // since info.version is required according to spec, swagger2openapi sets it to "" if missing + ? null // ...but that mocks with our multi-api-version treatment of inlining the api-version + : ServiceDefinition.Info.Version; CodeModel.Documentation = ServiceDefinition.Info.Description; CodeModel.BaseUrl = ServiceDefinition.Servers[0].Url.TrimEnd('/'); @@ -405,15 +407,30 @@ public SwaggerParameter Unwrap(SwaggerParameter swaggerParameter) // If referencing global parameters serializationProperty if (swaggerParameter.Reference != null) { - string referenceKey = swaggerParameter.Reference.StripComponentsParameterPath(); - if (!ServiceDefinition.Components.Parameters.ContainsKey(referenceKey)) + if (swaggerParameter.In == ParameterLocation.Body) { - throw new ArgumentException( - string.Format(CultureInfo.InvariantCulture, - Resources.DefinitionDoesNotExist, referenceKey)); + string referenceKey = swaggerParameter.Reference.StripComponentsRequestBodyPath(); + if (!ServiceDefinition.Components.RequestBodies.ContainsKey(referenceKey)) + { + throw new ArgumentException( + string.Format(CultureInfo.InvariantCulture, + Resources.DefinitionDoesNotExist, referenceKey)); + } + + swaggerParameter = ServiceDefinition.Components.RequestBodies[referenceKey].AsParameter(); } + else + { + string referenceKey = swaggerParameter.Reference.StripComponentsParameterPath(); + if (!ServiceDefinition.Components.Parameters.ContainsKey(referenceKey)) + { + throw new ArgumentException( + string.Format(CultureInfo.InvariantCulture, + Resources.DefinitionDoesNotExist, referenceKey)); + } - swaggerParameter = ServiceDefinition.Components.Parameters[referenceKey]; + swaggerParameter = ServiceDefinition.Components.Parameters[referenceKey]; + } } // Unwrap the schema if in "body" From 460616beb32334aaeb194ecd8568807bfc780dc1 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Wed, 1 Nov 2017 16:08:42 -0700 Subject: [PATCH 04/13] gooood --- src/Model/Operation.cs | 2 +- src/Model/RequestBody.cs | 20 ++++++++++---------- src/ParameterBuilder.cs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index e795f72..e350529 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -67,7 +67,7 @@ public IList Parameters var result = _parameters?.ToList(); if (RequestBody != null && result != null) { - result.Insert(RequestBody.Index, RequestBody.AsParameter()); + result.Insert(Extensions.Get("x-ms-requestBody-index") ?? 0, RequestBody.AsParameter()); } return result; } diff --git a/src/Model/RequestBody.cs b/src/Model/RequestBody.cs index 3ca03b8..c265ed0 100644 --- a/src/Model/RequestBody.cs +++ b/src/Model/RequestBody.cs @@ -26,16 +26,16 @@ public string Description public string Reference { get; set; } // TODO: get rid of this - public SwaggerParameter AsParameter() => new SwaggerParameter - { - Description = Description, - In = ParameterLocation.Body, - Name = Extensions.GetValue("x-ms-client-name") ?? "body", - IsRequired = Required, - Schema = Content?.Values.FirstOrDefault()?.Schema, - Reference = Reference - }; - public int Index => Extensions.Get("x-ms-requestBody-index") ?? 0; + public SwaggerParameter AsParameter() => + new SwaggerParameter + { + Description = Description, + In = ParameterLocation.Body, + Name = Extensions.GetValue("x-ms-client-name") ?? "body", + IsRequired = Required, + Schema = Content?.Values.FirstOrDefault()?.Schema, + Reference = Reference + }; public Dictionary Content { get; set; } diff --git a/src/ParameterBuilder.cs b/src/ParameterBuilder.cs index 49da289..4e587bb 100644 --- a/src/ParameterBuilder.cs +++ b/src/ParameterBuilder.cs @@ -45,6 +45,7 @@ public Parameter Build() parameterName = unwrappedParameter.Name; } + unwrappedParameter.IsRequired = unwrappedParameter.Schema.IsRequired = unwrappedParameter.IsRequired || unwrappedParameter.Schema.IsRequired || unwrappedParameter.In == AutoRest.Modeler.Model.ParameterLocation.Path; IModelType parameterType = BuildServiceType(parameterName); var parameter = New(new { @@ -53,7 +54,6 @@ public Parameter Build() ModelType = parameterType, Location = (Core.Model.ParameterLocation)Enum.Parse(typeof(Core.Model.ParameterLocation), unwrappedParameter.In.ToString()) }); - parameter.IsRequired = parameter.IsRequired || parameter.Location == Core.Model.ParameterLocation.Path; PopulateParameter(parameter, unwrappedParameter); if (_swaggerParameter.Reference != null) From 1fd7a1af9cd0b7bb5a16607853182df4737f07f6 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Thu, 2 Nov 2017 09:27:02 -0700 Subject: [PATCH 05/13] more stuffs --- src/Model/Header.cs | 17 +++++++++++++++-- src/Model/Operation.cs | 20 ++++++++++++++++++-- src/Model/SwaggerParameter.cs | 19 ++++--------------- src/OperationBuilder.cs | 4 ++-- src/ParameterBuilder.cs | 4 ++++ 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/Model/Header.cs b/src/Model/Header.cs index 312ddcf..f53b91f 100644 --- a/src/Model/Header.cs +++ b/src/Model/Header.cs @@ -2,13 +2,26 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; +using Newtonsoft.Json; namespace AutoRest.Modeler.Model { /// /// Swagger header object. /// - public class Header : SwaggerObject - { + public class Header : SwaggerBase + { + public string Description { get; set; } + + [JsonProperty(PropertyName = "$ref")] + public string Reference { get; set; } + + [JsonProperty(PropertyName = "required")] + public virtual bool IsRequired { get; set; } + + /// + /// The schema defining the type used for the body parameter. + /// + public Schema Schema { get; set; } } } \ No newline at end of file diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index e350529..5fd084f 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -49,10 +49,26 @@ public string Description public ExternalDoc ExternalDocs { get; set; } // TODO: fix/remove - public IList Consumes => new List { "application/json" }; + public IList Consumes + { + get + { + var result = RequestBody?.Content?.Keys.ToList(); + if (result == null || result.Count == 0) return new List { "application/json" }; + return result; + } + } // TODO: fix/remove - public IList Produces => new List { "application/json" }; + public IList Produces + { + get + { + var result = Responses?.Values.SelectMany(r => r.Content?.Keys ?? Enumerable.Empty()).Distinct().ToList(); + if (result == null || result.Count == 0) return new List { "application/json" }; + return result; + } + } IList _parameters; /// diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index fe9e3a9..338dc36 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -9,31 +9,20 @@ namespace AutoRest.Modeler.Model /// Describes a single operation parameter. /// https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#parameterObject /// - public class SwaggerParameter : SwaggerBase + public class SwaggerParameter : Header { - private bool _isRequired; public string Name { get; set; } - public string Description { get; set; } - - [JsonProperty(PropertyName = "$ref")] - public string Reference { get; set; } - public ParameterLocation In { get; set; } [JsonProperty(PropertyName = "required")] - public bool IsRequired + public override bool IsRequired { - get { return (_isRequired) || In == ParameterLocation.Path; } - set { _isRequired = value; } + get => base.IsRequired || In == ParameterLocation.Path; + set => base.IsRequired = value; } [JsonIgnore] public bool IsConstant => IsRequired && Schema?.Enum != null && Schema?.Enum.Count == 1; - - /// - /// The schema defining the type used for the body parameter. - /// - public Schema Schema { get; set; } } } \ No newline at end of file diff --git a/src/OperationBuilder.cs b/src/OperationBuilder.cs index ed1288e..341ce26 100644 --- a/src/OperationBuilder.cs +++ b/src/OperationBuilder.cs @@ -134,7 +134,7 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, Extensions = h.Value.Extensions, ModelType = New(new { - ValueType = h.Value.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key) + ValueType = h.Value.Schema.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key) }) }); headerType.Add(property); @@ -147,7 +147,7 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, SerializedName = h.Key, RealPath = new[] {h.Key}, Extensions = h.Value.Extensions, - ModelType = h.Value.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key), + ModelType = h.Value.Schema.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key), Documentation = h.Value.Description }); headerType.Add(property); diff --git a/src/ParameterBuilder.cs b/src/ParameterBuilder.cs index 4e587bb..778abc7 100644 --- a/src/ParameterBuilder.cs +++ b/src/ParameterBuilder.cs @@ -46,6 +46,10 @@ public Parameter Build() } unwrappedParameter.IsRequired = unwrappedParameter.Schema.IsRequired = unwrappedParameter.IsRequired || unwrappedParameter.Schema.IsRequired || unwrappedParameter.In == AutoRest.Modeler.Model.ParameterLocation.Path; + if (unwrappedParameter.Extensions.ContainsKey("x-ms-enum") && !unwrappedParameter.Schema.Extensions.ContainsKey("x-ms-enum")) + { + unwrappedParameter.Schema.Extensions["x-ms-enum"] = unwrappedParameter.Extensions["x-ms-enum"]; + } IModelType parameterType = BuildServiceType(parameterName); var parameter = New(new { From a5195afc2b472c145a9b1ea64bcf5eb5926e93fb Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Thu, 2 Nov 2017 11:06:27 -0700 Subject: [PATCH 06/13] discriminator --- src/Model/Discriminator.cs | 15 +++++++++++++++ src/Model/Schema.cs | 2 +- src/SchemaBuilder.cs | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/Model/Discriminator.cs diff --git a/src/Model/Discriminator.cs b/src/Model/Discriminator.cs new file mode 100644 index 0000000..66f3eb6 --- /dev/null +++ b/src/Model/Discriminator.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Collections.Generic; + +namespace AutoRest.Modeler.Model +{ + public class Discriminator + { + public string PropertyName { get; set; } + + // TODO: translate x-ms-discriminator-value to this! Completely ignored so far. + public Dictionary Mapping { get; set; } + } +} \ No newline at end of file diff --git a/src/Model/Schema.cs b/src/Model/Schema.cs index dc42fb0..760cb51 100644 --- a/src/Model/Schema.cs +++ b/src/Model/Schema.cs @@ -22,7 +22,7 @@ public class Schema : SwaggerObject /// the value MUST be the serviceTypeName of this schema or any schema that inherits it, /// or it can be overridden with the x-ms-discriminator-value extension. /// - public string Discriminator { get; set; } + public Discriminator Discriminator { get; set; } public bool? Nullable { get; set; } diff --git a/src/SchemaBuilder.cs b/src/SchemaBuilder.cs index f00a599..9f2d8d9 100644 --- a/src/SchemaBuilder.cs +++ b/src/SchemaBuilder.cs @@ -105,7 +105,7 @@ public override IModelType BuildServiceType(string serviceTypeName) foreach (var property in _schema.Properties) { string name = property.Key; - if (name != _schema.Discriminator) + if (name != _schema.Discriminator?.PropertyName) { string propertyServiceTypeName; Schema refSchema = null; From 6daff157b104fa486801c1ae2b75c24c643181f5 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Thu, 2 Nov 2017 16:29:19 -0700 Subject: [PATCH 07/13] un-clusterf***** --- .vscode/launch.json | 32 +++++++------ src/CollectionFormatBuilder.cs | 8 +--- .../SchemaRequiredItemConverter.cs | 45 ------------------- src/Model/Operation.cs | 13 +++--- src/Model/ParameterLocation.cs | 3 +- src/Model/ParameterStyle.cs | 18 ++++++++ src/Model/RequestBody.cs | 45 +++++++++++++++---- src/Model/SwaggerObject.cs | 6 --- src/Model/SwaggerParameter.cs | 33 ++++++++++++++ src/ObjectBuilder.cs | 25 +++++------ src/OperationBuilder.cs | 21 +++++---- src/ParameterBuilder.cs | 20 ++++++--- src/SchemaBuilder.cs | 29 +++++------- src/SwaggerModeler.cs | 4 +- src/SwaggerParser.cs | 1 - 15 files changed, 168 insertions(+), 135 deletions(-) delete mode 100644 src/JsonConverters/SchemaRequiredItemConverter.cs create mode 100644 src/Model/ParameterStyle.cs diff --git a/.vscode/launch.json b/.vscode/launch.json index 6c17d76..0b234c4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,14 +1,20 @@ { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] - } \ No newline at end of file + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "attach", + "name": "Attach", + "port": 9229 + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/src/CollectionFormatBuilder.cs b/src/CollectionFormatBuilder.cs index 90df2f9..06c5f96 100644 --- a/src/CollectionFormatBuilder.cs +++ b/src/CollectionFormatBuilder.cs @@ -23,13 +23,7 @@ public static StringBuilder OnBuildMethodParameter(Method method, throw new ArgumentNullException("currentSwaggerParam"); } - bool hasCollectionFormat = currentSwaggerParam.Schema?.CollectionFormat != CollectionFormat.None; - - if (currentSwaggerParam.Schema?.Type == DataType.Array && !hasCollectionFormat) - { - // If the parameter type is array default the collectionFormat to csv - currentSwaggerParam.Schema.CollectionFormat = CollectionFormat.Csv; - } + bool hasCollectionFormat = currentSwaggerParam.CollectionFormat != CollectionFormat.None; if (hasCollectionFormat) { diff --git a/src/JsonConverters/SchemaRequiredItemConverter.cs b/src/JsonConverters/SchemaRequiredItemConverter.cs deleted file mode 100644 index ad0fe21..0000000 --- a/src/JsonConverters/SchemaRequiredItemConverter.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using AutoRest.Core.Utilities; -using AutoRest.Modeler.Model; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace AutoRest.Modeler.JsonConverters -{ - public class SchemaRequiredItemConverter : SwaggerJsonConverter - { - public override bool CanConvert(Type objectType) - { - return objectType == typeof (Schema); - } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, - JsonSerializer serializer) - { - JObject jo = JObject.Load(reader); - var schema = JsonConvert.DeserializeObject(jo.ToString(), - GetSettings(serializer)); - - //Per JSON schema 4.0, each node uses the "IsRequired" field (an array) to call out mandatory properties. - foreach (var key in schema.Required ?? Enumerable.Empty()) - { - if (schema.Properties != null && schema.Properties.TryGetValue(key, out var value)) - { - value.IsRequired = true; - } - else - { - // see https://github.com/Azure/autorest/issues/2210 - // throw new Exception($"Required property '{key}' does not exist in the schema."); - } - } - - return schema; - } - } -} \ No newline at end of file diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index 5fd084f..601c552 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Collections.Generic; using AutoRest.Core.Utilities; +using Newtonsoft.Json; namespace AutoRest.Modeler.Model { @@ -70,22 +71,24 @@ public IList Produces } } + [JsonIgnore] IList _parameters; /// /// A list of parameters that are applicable for this operation. /// If a parameter is already defined at the Path Item, the /// new definition will override it, but can never remove it. /// - public IList Parameters + [JsonProperty(PropertyName = "parameters")] + public SwaggerParameter[] Parameters { get { - var result = _parameters?.ToList(); - if (RequestBody != null && result != null) + var result = _parameters?.ToList() ?? new List(); + if (RequestBody != null) { - result.Insert(Extensions.Get("x-ms-requestBody-index") ?? 0, RequestBody.AsParameter()); + result.InsertRange(Math.Min(Extensions.Get("x-ms-requestBody-index") ?? 0, result.Count), RequestBody.AsParameters()); } - return result; + return result.ToArray(); } set => _parameters = value.Where(v => v.In != ParameterLocation.Body).ToList(); } // TODO: not like this... diff --git a/src/Model/ParameterLocation.cs b/src/Model/ParameterLocation.cs index d030808..51bae1f 100644 --- a/src/Model/ParameterLocation.cs +++ b/src/Model/ParameterLocation.cs @@ -13,6 +13,7 @@ public enum ParameterLocation Header, Path, FormData, - Body + Body, + Cookie } } diff --git a/src/Model/ParameterStyle.cs b/src/Model/ParameterStyle.cs new file mode 100644 index 0000000..c0d8339 --- /dev/null +++ b/src/Model/ParameterStyle.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + + +namespace AutoRest.Modeler.Model +{ + public enum ParameterStyle + { + Matrix, + Label, + Form, + Simple, + SpaceDelimited, + PipeDelimited, + DeepObject, + TabDelimited // FAKE + } +} \ No newline at end of file diff --git a/src/Model/RequestBody.cs b/src/Model/RequestBody.cs index c265ed0..078b225 100644 --- a/src/Model/RequestBody.cs +++ b/src/Model/RequestBody.cs @@ -26,16 +26,43 @@ public string Description public string Reference { get; set; } // TODO: get rid of this - public SwaggerParameter AsParameter() => - new SwaggerParameter + private IEnumerable asParamCache = null; + public IEnumerable AsParameters() + { + if (asParamCache == null) { - Description = Description, - In = ParameterLocation.Body, - Name = Extensions.GetValue("x-ms-client-name") ?? "body", - IsRequired = Required, - Schema = Content?.Values.FirstOrDefault()?.Schema, - Reference = Reference - }; + var isFormData = Content?.Keys?.FirstOrDefault() == "multipart/form-data" && Content.Values.First().Schema != null; + if (isFormData) // => in: form-data + { + var schema = Content.Values.First().Schema; + asParamCache = schema.Properties.Select(prop => + new SwaggerParameter + { + Description = prop.Value.Description, + In = ParameterLocation.FormData, + Name = prop.Key, + IsRequired = schema.Required.Contains(prop.Key), + Schema = prop.Value, + Extensions = schema.Extensions + }); + } + else // => in: body + { + var p = new SwaggerParameter + { + Description = Description, + In = ParameterLocation.Body, + Name = Extensions.GetValue("x-ms-client-name") ?? "body", + IsRequired = Required, + Schema = Content?.Values.FirstOrDefault()?.Schema, + Reference = Reference, + Extensions = Extensions + }; + asParamCache = new [] { p }; + } + } + return asParamCache; + } public Dictionary Content { get; set; } diff --git a/src/Model/SwaggerObject.cs b/src/Model/SwaggerObject.cs index 8a7a5ea..181f633 100644 --- a/src/Model/SwaggerObject.cs +++ b/src/Model/SwaggerObject.cs @@ -19,7 +19,6 @@ namespace AutoRest.Modeler.Model public abstract class SwaggerObject : SwaggerBase { private string _description; - public virtual bool IsRequired { get; set; } /// /// The type of the parameter. @@ -56,11 +55,6 @@ public virtual string Description set { _description = value.StripControlCharacters(); } } - /// - /// Determines the format of the array if type array is used. - /// - public virtual CollectionFormat CollectionFormat { get; set; } - /// /// Sets a default value to the parameter. /// diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index 338dc36..dcc5c2b 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using AutoRest.Core.Model; using Newtonsoft.Json; namespace AutoRest.Modeler.Model @@ -15,6 +16,36 @@ public class SwaggerParameter : Header public ParameterLocation In { get; set; } + public ParameterStyle? Style { get; set; } + + public bool? Explode { get; set; } + + // TODO: remove + public CollectionFormat CollectionFormat + { + get + { + var style = Style ?? (In == ParameterLocation.Query || In == ParameterLocation.Cookie ? ParameterStyle.Form : ParameterStyle.Simple); + var explode = Explode ?? (style == ParameterStyle.Form); + if (explode) + { + return CollectionFormat.Multi; + } + switch (style) + { + case ParameterStyle.Simple: + return CollectionFormat.Csv; + case ParameterStyle.SpaceDelimited: + return CollectionFormat.Ssv; + case ParameterStyle.PipeDelimited: + return CollectionFormat.Pipes; + case ParameterStyle.TabDelimited: //FAKE + return CollectionFormat.Tsv; + } + return CollectionFormat.Csv; + } + } + [JsonProperty(PropertyName = "required")] public override bool IsRequired { @@ -24,5 +55,7 @@ public override bool IsRequired [JsonIgnore] public bool IsConstant => IsRequired && Schema?.Enum != null && Schema?.Enum.Count == 1; + + public bool? AllowReserved { get; set; } } } \ No newline at end of file diff --git a/src/ObjectBuilder.cs b/src/ObjectBuilder.cs index c36d26e..5e88436 100644 --- a/src/ObjectBuilder.cs +++ b/src/ObjectBuilder.cs @@ -32,7 +32,7 @@ public ObjectBuilder(SwaggerObject swaggerObject, SwaggerModeler modeler) Modeler = modeler; } - public virtual IModelType ParentBuildServiceType(string serviceTypeName) + public virtual IModelType ParentBuildServiceType(string serviceTypeName, bool required) { // Should not try to get parent from generic swagger object builder throw new InvalidOperationException(); @@ -44,7 +44,7 @@ public virtual IModelType ParentBuildServiceType(string serviceTypeName) /// /// name for the service type /// built service type - public virtual IModelType BuildServiceType(string serviceTypeName) + public virtual IModelType BuildServiceType(string serviceTypeName, bool required) { PrimaryType type = SwaggerObject.ToType(); Debug.Assert(type != null); @@ -56,7 +56,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) type.XmlProperties = (SwaggerObject as Schema)?.Xml; type.Format = SwaggerObject.Format; var xMsEnum = SwaggerObject.Extensions.GetValue(Core.Model.XmsExtensions.Enum.Name); - if ((SwaggerObject.Enum != null || xMsEnum != null) && type.KnownPrimaryType == KnownPrimaryType.String && !(IsSwaggerObjectConstant(SwaggerObject))) + if ((SwaggerObject.Enum != null || xMsEnum != null) && type.KnownPrimaryType == KnownPrimaryType.String && !(IsSwaggerObjectConstant(SwaggerObject, required))) { var enumType = New(); // Set the underlying type. This helps to determine whether the values in EnumValue are of type string, number, etc. @@ -159,7 +159,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) } var elementType = - SwaggerObject.Items.GetBuilder(Modeler).BuildServiceType(itemServiceTypeName); + SwaggerObject.Items.GetBuilder(Modeler).BuildServiceType(itemServiceTypeName, false); return New(new { ElementType = elementType, @@ -183,7 +183,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) { ValueType = SwaggerObject.AdditionalProperties.GetBuilder(Modeler) - .BuildServiceType((dictionaryValueServiceTypeName)), + .BuildServiceType(dictionaryValueServiceTypeName, false), Extensions = SwaggerObject.AdditionalProperties.Extensions, XmlProperties = (SwaggerObject as Schema)?.Xml }); @@ -192,7 +192,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) return type; } - public static void PopulateParameter(IVariable parameter, SwaggerObject swaggerObject) + public static void PopulateParameter(Property parameter, SwaggerObject swaggerObject) { if (swaggerObject == null) { @@ -202,17 +202,16 @@ public static void PopulateParameter(IVariable parameter, SwaggerObject swaggerO { throw new ArgumentNullException("parameter"); } - parameter.IsRequired = swaggerObject.IsRequired; parameter.DefaultValue = swaggerObject.Default; - if (IsSwaggerObjectConstant(swaggerObject)) + if (IsSwaggerObjectConstant(swaggerObject, parameter.IsRequired)) { parameter.DefaultValue = swaggerObject.Enum[0]; parameter.IsConstant = true; } parameter.Documentation = swaggerObject.Description; - parameter.CollectionFormat = swaggerObject.CollectionFormat; + // parameter.CollectionFormat = swaggerObject.CollectionFormat; // tag the paramter with all the extensions from the swagger object parameter.Extensions.AddRange(swaggerObject.Extensions); @@ -233,14 +232,14 @@ public static void PopulateParameter(IVariable parameter, SwaggerParameter swagg parameter.IsRequired = swaggerObject.IsRequired; parameter.DefaultValue = swaggerObject.Schema?.Default; - if (IsSwaggerObjectConstant(swaggerObject.Schema)) + if (IsSwaggerObjectConstant(swaggerObject.Schema, parameter.IsRequired)) { parameter.DefaultValue = swaggerObject.Schema.Enum[0]; parameter.IsConstant = true; } parameter.Documentation = swaggerObject.Description; - parameter.CollectionFormat = swaggerObject.Schema.CollectionFormat; + parameter.CollectionFormat = swaggerObject.CollectionFormat; // tag the paramter with all the extensions from the swagger object parameter.Extensions.AddRange(swaggerObject.Extensions); @@ -248,9 +247,9 @@ public static void PopulateParameter(IVariable parameter, SwaggerParameter swagg SetConstraints(parameter.Constraints, swaggerObject.Schema); } - private static bool IsSwaggerObjectConstant(SwaggerObject swaggerObject) + private static bool IsSwaggerObjectConstant(SwaggerObject swaggerObject, bool isRequired) { - return (swaggerObject.Enum != null && swaggerObject.Enum.Count == 1 && swaggerObject.IsRequired); + return (swaggerObject.Enum != null && swaggerObject.Enum.Count == 1 && isRequired); } public static void SetConstraints(Dictionary constraints, SwaggerObject swaggerObject) diff --git a/src/OperationBuilder.cs b/src/OperationBuilder.cs index 341ce26..4fef27c 100644 --- a/src/OperationBuilder.cs +++ b/src/OperationBuilder.cs @@ -104,7 +104,7 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, { MetadataPropertyHandling = MetadataPropertyHandling.Ignore })); - headerTypeReferences.Add(schema.GetBuilder(_swaggerModeler).BuildServiceType(headerTypeName)); + headerTypeReferences.Add(schema.GetBuilder(_swaggerModeler).BuildServiceType(headerTypeName, false)); } else { @@ -124,6 +124,11 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, }); foreach (var h in responseHeaders) { + var hv = h.Value; + if (hv.Extensions.ContainsKey("x-ms-enum") && !hv.Schema.Extensions.ContainsKey("x-ms-enum")) + { + hv.Schema.Extensions["x-ms-enum"] = hv.Extensions["x-ms-enum"]; + } if (h.Value.Extensions != null && h.Value.Extensions.ContainsKey("x-ms-header-collection-prefix")) { var property = New(new @@ -131,10 +136,10 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, Name = h.Key, SerializedName = h.Key, RealPath = new[] {h.Key}, - Extensions = h.Value.Extensions, + Extensions = hv.Extensions, ModelType = New(new { - ValueType = h.Value.Schema.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key) + ValueType = hv.Schema.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key, false) }) }); headerType.Add(property); @@ -146,9 +151,9 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, Name = h.Key, SerializedName = h.Key, RealPath = new[] {h.Key}, - Extensions = h.Value.Extensions, - ModelType = h.Value.Schema.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key), - Documentation = h.Value.Description + Extensions = hv.Extensions, + ModelType = hv.Schema.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key, false), + Documentation = hv.Description }); headerType.Add(property); } @@ -367,7 +372,7 @@ private bool TryBuildStreamResponse(HttpStatusCode responseStatusCode, Operation if (response.Schema != null) { IModelType serviceType = response.Schema.GetBuilder(_swaggerModeler) - .BuildServiceType(response.Schema.Reference.StripComponentsSchemaPath()); + .BuildServiceType(response.Schema.Reference.StripComponentsSchemaPath(), false); Debug.Assert(serviceType != null); @@ -480,7 +485,7 @@ private bool TryBuildResponseBody(string methodName, OperationResponse response, referenceKey = typeNamer(methodName); } - responseType = response.Schema.GetBuilder(_swaggerModeler).BuildServiceType(referenceKey); + responseType = response.Schema.GetBuilder(_swaggerModeler).BuildServiceType(referenceKey, false); handled = true; } } diff --git a/src/ParameterBuilder.cs b/src/ParameterBuilder.cs index 778abc7..68006c6 100644 --- a/src/ParameterBuilder.cs +++ b/src/ParameterBuilder.cs @@ -45,12 +45,13 @@ public Parameter Build() parameterName = unwrappedParameter.Name; } - unwrappedParameter.IsRequired = unwrappedParameter.Schema.IsRequired = unwrappedParameter.IsRequired || unwrappedParameter.Schema.IsRequired || unwrappedParameter.In == AutoRest.Modeler.Model.ParameterLocation.Path; + var isRequired = unwrappedParameter.IsRequired || unwrappedParameter.In == AutoRest.Modeler.Model.ParameterLocation.Path; + unwrappedParameter.IsRequired = isRequired; if (unwrappedParameter.Extensions.ContainsKey("x-ms-enum") && !unwrappedParameter.Schema.Extensions.ContainsKey("x-ms-enum")) { unwrappedParameter.Schema.Extensions["x-ms-enum"] = unwrappedParameter.Extensions["x-ms-enum"]; } - IModelType parameterType = BuildServiceType(parameterName); + IModelType parameterType = BuildServiceType(parameterName, isRequired); var parameter = New(new { Name = unwrappedParameter.Name, @@ -58,6 +59,13 @@ public Parameter Build() ModelType = parameterType, Location = (Core.Model.ParameterLocation)Enum.Parse(typeof(Core.Model.ParameterLocation), unwrappedParameter.In.ToString()) }); + + // translate allowReserved back to what "code-model-v1"-gen generators expect + if (unwrappedParameter.AllowReserved.HasValue && !parameter.Extensions.ContainsKey("x-ms-skip-url-encoding")) + { + parameter.Extensions["x-ms-skip-url-encoding"] = unwrappedParameter.AllowReserved.Value; + } + PopulateParameter(parameter, unwrappedParameter); if (_swaggerParameter.Reference != null) @@ -69,7 +77,7 @@ public Parameter Build() return parameter; } - public override IModelType BuildServiceType(string serviceTypeName) + public override IModelType BuildServiceType(string serviceTypeName, bool required) { var swaggerParameter = Modeler.Unwrap(_swaggerParameter); @@ -80,12 +88,12 @@ public override IModelType BuildServiceType(string serviceTypeName) { throw new Exception($"Invalid Swagger: Body parameter{(serviceTypeName == null ? "" : $" '{serviceTypeName}'")} missing 'schema'."); } - return swaggerParameter.Schema.GetBuilder(Modeler).BuildServiceType(serviceTypeName); + return swaggerParameter.Schema.GetBuilder(Modeler).BuildServiceType(serviceTypeName, swaggerParameter.IsRequired); } - return swaggerParameter.GetBuilder(Modeler).ParentBuildServiceType(serviceTypeName); + return swaggerParameter.GetBuilder(Modeler).ParentBuildServiceType(serviceTypeName, swaggerParameter.IsRequired); } - public override IModelType ParentBuildServiceType(string serviceTypeName) => base.BuildServiceType(serviceTypeName); + public override IModelType ParentBuildServiceType(string serviceTypeName, bool required) => base.BuildServiceType(serviceTypeName, required); } } \ No newline at end of file diff --git a/src/SchemaBuilder.cs b/src/SchemaBuilder.cs index 9f2d8d9..451d2d6 100644 --- a/src/SchemaBuilder.cs +++ b/src/SchemaBuilder.cs @@ -30,7 +30,7 @@ public SchemaBuilder(Schema schema, SwaggerModeler modeler) _schema = schema; } - public override IModelType BuildServiceType(string serviceTypeName) + public override IModelType BuildServiceType(string serviceTypeName, bool required) { _schema = Modeler.Resolver.Unwrap(_schema); @@ -43,7 +43,7 @@ public override IModelType BuildServiceType(string serviceTypeName) // If it's a primitive type, let the parent build service handle it if (_schema.IsPrimitiveType()) { - return _schema.GetBuilder(Modeler).ParentBuildServiceType(serviceTypeName); + return _schema.GetBuilder(Modeler).ParentBuildServiceType(serviceTypeName, required); } // If it's known primary type, return that type @@ -83,7 +83,7 @@ public override IModelType BuildServiceType(string serviceTypeName) ValueType = _schema.AdditionalProperties.GetBuilder(Modeler).BuildServiceType( _schema.AdditionalProperties.Reference != null ? _schema.AdditionalProperties.Reference.StripComponentsSchemaPath() - : serviceTypeName + "Value"), + : serviceTypeName + "Value", false), Extensions = _schema.AdditionalProperties.Extensions, SupportsAdditionalProperties = true }); @@ -110,12 +110,6 @@ public override IModelType BuildServiceType(string serviceTypeName) string propertyServiceTypeName; Schema refSchema = null; - if (property.Value.ReadOnly && property.Value.IsRequired) - { - throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, - Resources.ReadOnlyNotRequired, name, serviceTypeName)); - } - if (property.Value.Reference != null) { propertyServiceTypeName = property.Value.Reference.StripComponentsSchemaPath(); @@ -125,10 +119,6 @@ public override IModelType BuildServiceType(string serviceTypeName) if (unwrappedSchema.Enum != null) { refSchema = new Schema().LoadFrom(unwrappedSchema); - if (property.Value.IsRequired) - { - refSchema.IsRequired = property.Value.IsRequired; - } //Todo: Remove the following when referenced descriptions are correctly ignored (Issue https://github.com/Azure/autorest/issues/1283) refSchema.Description = property.Value.Description; } @@ -137,10 +127,10 @@ public override IModelType BuildServiceType(string serviceTypeName) { propertyServiceTypeName = serviceTypeName + "_" + property.Key; } - + var isRequired = _schema.Required?.Contains(property.Key) ?? false; var propertyType = refSchema != null - ? refSchema.GetBuilder(Modeler).BuildServiceType(propertyServiceTypeName) - : property.Value.GetBuilder(Modeler).BuildServiceType(propertyServiceTypeName); + ? refSchema.GetBuilder(Modeler).BuildServiceType(propertyServiceTypeName, isRequired) + : property.Value.GetBuilder(Modeler).BuildServiceType(propertyServiceTypeName, isRequired); var propertyObj = New(new { @@ -150,7 +140,8 @@ public override IModelType BuildServiceType(string serviceTypeName) ModelType = propertyType, IsReadOnly = property.Value.ReadOnly, Summary = property.Value.Title, - XmlProperties = property.Value.Xml + XmlProperties = property.Value.Xml, + IsRequired = isRequired }); PopulateParameter(propertyObj, refSchema != null ? refSchema : property.Value); var propertyCompositeType = propertyType as CompositeType; @@ -210,9 +201,9 @@ public override IModelType BuildServiceType(string serviceTypeName) return objectType; } - public override IModelType ParentBuildServiceType(string serviceTypeName) + public override IModelType ParentBuildServiceType(string serviceTypeName, bool required) { - return base.BuildServiceType(serviceTypeName); + return base.BuildServiceType(serviceTypeName, required); } } } \ No newline at end of file diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index 01b74cd..322cf69 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -298,7 +298,7 @@ public virtual void BuildCompositeTypes() foreach (var schemaName in schemas.Keys.ToArray()) { var schema = schemas[schemaName]; - schema.GetBuilder(this).BuildServiceType(schemaName); + schema.GetBuilder(this).BuildServiceType(schemaName, false); Resolver.ExpandAllOf(schema); var parent = string.IsNullOrEmpty(schema.Extends.StripComponentsSchemaPath()) @@ -417,7 +417,7 @@ public SwaggerParameter Unwrap(SwaggerParameter swaggerParameter) Resources.DefinitionDoesNotExist, referenceKey)); } - swaggerParameter = ServiceDefinition.Components.RequestBodies[referenceKey].AsParameter(); + swaggerParameter = ServiceDefinition.Components.RequestBodies[referenceKey].AsParameters().First(); } else { diff --git a/src/SwaggerParser.cs b/src/SwaggerParser.cs index fe2d526..bc2518c 100644 --- a/src/SwaggerParser.cs +++ b/src/SwaggerParser.cs @@ -40,7 +40,6 @@ public static ServiceDefinition Parse(string swaggerDocument) settings.Converters.Add(new ResponseRefConverter(swaggerDocument)); settings.Converters.Add(new PathItemRefConverter(swaggerDocument)); settings.Converters.Add(new PathLevelParameterConverter(swaggerDocument)); - settings.Converters.Add(new SchemaRequiredItemConverter()); settings.Converters.Add(new SecurityDefinitionConverter()); var swaggerService = JsonConvert.DeserializeObject(swaggerDocument, settings); From 9e0331e7b3a7a23e62bf02ae35ba389bd10de086 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Thu, 2 Nov 2017 16:54:53 -0700 Subject: [PATCH 08/13] did... something... about CollectionFormat.None --- src/CollectionFormatBuilder.cs | 6 ++++++ src/Model/SwaggerParameter.cs | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/CollectionFormatBuilder.cs b/src/CollectionFormatBuilder.cs index 06c5f96..b152cd8 100644 --- a/src/CollectionFormatBuilder.cs +++ b/src/CollectionFormatBuilder.cs @@ -25,6 +25,12 @@ public static StringBuilder OnBuildMethodParameter(Method method, bool hasCollectionFormat = currentSwaggerParam.CollectionFormat != CollectionFormat.None; + if (currentSwaggerParam.Schema?.Type == DataType.Array && !hasCollectionFormat) + { + // If the parameter type is array default the collectionFormat to csv + currentSwaggerParam.Style = ParameterStyle.Simple; + } + if (hasCollectionFormat) { if (currentSwaggerParam.In == ParameterLocation.Path) diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index dcc5c2b..1fbd120 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -25,6 +25,11 @@ public CollectionFormat CollectionFormat { get { + bool quirksMode = true; // disable/make settable as appropriate + if (!Style.HasValue && !Explode.HasValue && quirksMode) + { + return CollectionFormat.None; // WAT + } var style = Style ?? (In == ParameterLocation.Query || In == ParameterLocation.Cookie ? ParameterStyle.Form : ParameterStyle.Simple); var explode = Explode ?? (style == ParameterStyle.Form); if (explode) @@ -42,7 +47,7 @@ public CollectionFormat CollectionFormat case ParameterStyle.TabDelimited: //FAKE return CollectionFormat.Tsv; } - return CollectionFormat.Csv; + throw new System.NotImplementedException($"Style '{style}' is not yet supported."); } } From 719affe9aa4047abad19b532d2f5f431d4c649e0 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Thu, 2 Nov 2017 19:39:06 -0700 Subject: [PATCH 09/13] convert and fix tests --- src/JsonConverters/ResponseRefConverter.cs | 7 +- src/Model/Components.cs | 6 + src/Model/Operation.cs | 2 +- src/Model/ServiceDefinition.cs | 6 - src/Properties/Resources.Designer.cs | 9 - src/Properties/Resources.resx | 3 - src/SwaggerModeler.cs | 5 - .../SerializationTests.json | 72 +- .../Comparison/Modified/misc_checks_01.json | 84 - .../Comparison/Modified/misc_checks_02.json | 46 - .../Modified/operation_check_01.json | 115 -- .../Modified/operation_check_02.json | 149 -- .../Modified/operation_check_03.json | 59 - .../Modified/operation_check_04.json | 124 -- .../Modified/operation_check_05.json | 112 -- .../Comparison/Modified/param_check_01.json | 122 -- .../Modified/response_check_01.json | 116 -- .../Comparison/Modified/version_check_01.json | 9 - .../Comparison/Modified/version_check_02.json | 9 - .../Comparison/Modified/version_check_03.json | 9 - .../Comparison/Modified/version_check_04.json | 9 - .../Comparison/Original/misc_checks_01.json | 105 - .../Comparison/Original/misc_checks_02.json | 60 - .../Original/operation_check_01.json | 115 -- .../Original/operation_check_02.json | 149 -- .../Original/operation_check_03.json | 58 - .../Original/operation_check_04.json | 124 -- .../Original/operation_check_05.json | 112 -- .../Comparison/Original/param_check_01.json | 122 -- .../Original/response_check_01.json | 116 -- .../Comparison/Original/version_check_01.json | 9 - .../Comparison/Original/version_check_02.json | 9 - .../Comparison/Original/version_check_03.json | 9 - .../Comparison/Original/version_check_04.json | 9 - .../swagger/applicationGateway.json | 97 - .../2016-09-01/swagger/networkInterface.json | 126 +- .../swagger/applicationGateway.json | 230 +-- .../2016-12-01/swagger/network.json | 263 +-- .../swagger-additional-properties.yaml | 304 +-- .../Swagger/swagger-allOf-circular.json | 1136 ++++++++--- test/Resource/Swagger/swagger-allOf.json | 908 +++++++-- .../Swagger/swagger-composite-constants.json | 1702 ++++++++--------- test/Resource/Swagger/swagger-data-types.json | 675 ++++--- .../Swagger/swagger-external-def.json | 183 +- .../swagger-external-ref-no-definitions.json | 64 +- .../Swagger/swagger-external-ref.json | 118 +- .../Swagger/swagger-global-responses.json | 148 +- .../swagger-multiple-response-schemas.json | 1481 +++++++++++--- test/Resource/Swagger/swagger-no-content.json | 518 +++-- .../Swagger/swagger-optional-params.json | 228 ++- .../Swagger/swagger-polymorphism.json | 294 +-- .../Swagger/swagger-recursive-type.json | 119 +- .../swagger-ref-allOf-inheritance.json | 476 ++--- .../Swagger/swagger-response-headers.json | 224 ++- .../Resource/Swagger/swagger-simple-spec.json | 200 +- .../Resource/Swagger/swagger-simple-spec.yaml | 333 ++-- test/Resource/Swagger/swagger-streaming.json | 135 +- test/Resource/Swagger/swagger-validation.json | 327 ++-- ...swagger-x-ms-code-generation-settings.json | 18 +- .../swagger-x-ms-discriminator-value.json | 760 ++++++-- .../swagger-x-ms-parameterized-host.json | 48 +- test/Resource/Swagger/swagger-x-ms-paths.json | 95 +- test/Resource/Swagger/swagger-xml-paths.yaml | 71 +- test/Resource/Swagger/swagger-xml.yaml | 118 +- .../Swagger/vendor-extension-in-path.json | 30 +- test/SerializationTests.cs | 4 +- test/SwaggerModelerTests.cs | 5 +- 67 files changed, 7255 insertions(+), 6253 deletions(-) delete mode 100644 test/Resource/Swagger/Comparison/Modified/misc_checks_01.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/misc_checks_02.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/operation_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/operation_check_02.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/operation_check_03.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/operation_check_04.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/operation_check_05.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/param_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/response_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/version_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/version_check_02.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/version_check_03.json delete mode 100644 test/Resource/Swagger/Comparison/Modified/version_check_04.json delete mode 100644 test/Resource/Swagger/Comparison/Original/misc_checks_01.json delete mode 100644 test/Resource/Swagger/Comparison/Original/misc_checks_02.json delete mode 100644 test/Resource/Swagger/Comparison/Original/operation_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Original/operation_check_02.json delete mode 100644 test/Resource/Swagger/Comparison/Original/operation_check_03.json delete mode 100644 test/Resource/Swagger/Comparison/Original/operation_check_04.json delete mode 100644 test/Resource/Swagger/Comparison/Original/operation_check_05.json delete mode 100644 test/Resource/Swagger/Comparison/Original/param_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Original/response_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Original/version_check_01.json delete mode 100644 test/Resource/Swagger/Comparison/Original/version_check_02.json delete mode 100644 test/Resource/Swagger/Comparison/Original/version_check_03.json delete mode 100644 test/Resource/Swagger/Comparison/Original/version_check_04.json delete mode 100644 test/Resource/Swagger/arm-network/2016-09-01/swagger/applicationGateway.json diff --git a/src/JsonConverters/ResponseRefConverter.cs b/src/JsonConverters/ResponseRefConverter.cs index d917a38..894c8c2 100644 --- a/src/JsonConverters/ResponseRefConverter.cs +++ b/src/JsonConverters/ResponseRefConverter.cs @@ -30,15 +30,14 @@ public override object ReadJson(JsonReader reader, System.Type objectType, objec { referencePath = jo.GetValue("$ref", StringComparison.Ordinal).ToString(); // Shorthand notation - if (!referencePath.StartsWith("#/responses", StringComparison.Ordinal)) + if (!referencePath.StartsWith("#/components/responses", StringComparison.Ordinal)) { - referencePath = "#/responses/" + referencePath; + referencePath = "#/components/responses/" + referencePath; } jo = Document.SelectToken(referencePath.Replace("#/", "").Replace("/", ".")) as JObject; } - OperationResponse swaggerResponse = JsonConvert.DeserializeObject(jo.ToString(), - GetSettings(serializer)); + OperationResponse swaggerResponse = JsonConvert.DeserializeObject(jo.ToString(), GetSettings(serializer)); return swaggerResponse; } } diff --git a/src/Model/Components.cs b/src/Model/Components.cs index 493f69c..c433e39 100644 --- a/src/Model/Components.cs +++ b/src/Model/Components.cs @@ -12,6 +12,7 @@ public Components() Schemas = new Dictionary(); Parameters = new Dictionary(); Responses = new Dictionary(); + SecuritySchemes = new Dictionary(); } /// @@ -32,5 +33,10 @@ public Components() /// public Dictionary Responses { get; set; } + /// + /// Key is the object serviceTypeName and the value is swagger security definition. + /// + public Dictionary SecuritySchemes { get; set; } + } } \ No newline at end of file diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index 601c552..790b51b 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -66,7 +66,7 @@ public IList Produces get { var result = Responses?.Values.SelectMany(r => r.Content?.Keys ?? Enumerable.Empty()).Distinct().ToList(); - if (result == null || result.Count == 0) return new List { "application/json" }; + if (result == null || result.Count == 0 || result.Count == 1 && result[0] == "*/*") return new List { "application/json" }; return result; } } diff --git a/src/Model/ServiceDefinition.cs b/src/Model/ServiceDefinition.cs index 0f0149c..24e60ac 100644 --- a/src/Model/ServiceDefinition.cs +++ b/src/Model/ServiceDefinition.cs @@ -20,7 +20,6 @@ public ServiceDefinition() Schemes = new List(); Paths = new Dictionary>(); CustomPaths = new Dictionary>(); - SecurityDefinitions = new Dictionary(); Security = new List>>(); Tags = new List(); } @@ -66,11 +65,6 @@ public ServiceDefinition() public Components Components { get; set; } - /// - /// Key is the object serviceTypeName and the value is swagger security definition. - /// - public Dictionary SecurityDefinitions { get; set; } - /// /// A declaration of which security schemes are applied for the API as a whole. /// The list of values describes alternative security schemes that can be used diff --git a/src/Properties/Resources.Designer.cs b/src/Properties/Resources.Designer.cs index a8ee839..54d79ab 100644 --- a/src/Properties/Resources.Designer.cs +++ b/src/Properties/Resources.Designer.cs @@ -266,15 +266,6 @@ public static string TitleMissing { } } - /// - /// Looks up a localized string similar to Invalid swagger 2.0 specification. Missing version property. . - /// - public static string UnknownSwaggerVersion { - get { - return ResourceManager.GetString("UnknownSwaggerVersion", resourceCulture); - } - } - /// /// Looks up a localized string similar to The operation '{0}' has a response body in response '{1}', but did not have a supported MIME type ('application/json' or 'application/octet-stream') in its Produces property.. /// diff --git a/src/Properties/Resources.resx b/src/Properties/Resources.resx index 41cbc45..bf611bd 100644 --- a/src/Properties/Resources.resx +++ b/src/Properties/Resources.resx @@ -186,9 +186,6 @@ Swagger specification is missing title in info section - - Invalid swagger 2.0 specification. Missing version property. - The operation '{0}' has a response body in response '{1}', but did not have a supported MIME type ('application/json' or 'application/octet-stream') in its Produces property. diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index 322cf69..35fba2e 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -168,11 +168,6 @@ private void UpdateSettings() /// The base ServiceModel Service private void InitializeClientModel() { - if (string.IsNullOrEmpty(ServiceDefinition.OpenApi)) - { - throw ErrorManager.CreateError(Resources.UnknownSwaggerVersion); - } - if (ServiceDefinition.Info == null) { throw ErrorManager.CreateError(Resources.InfoSectionMissing); diff --git a/test/Resource/SerializationTests/SerializationTests.json b/test/Resource/SerializationTests/SerializationTests.json index fe4f030..d607e44 100644 --- a/test/Resource/SerializationTests/SerializationTests.json +++ b/test/Resource/SerializationTests/SerializationTests.json @@ -1,34 +1,40 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.9-abcd", - "title": "Swagger Sample API" - }, - "paths": { - "/pets/": { - "get": { - "responses": { - "200": { - "description": "pet response" - } - } - } - } - }, - "securityDefinitions": { - "petstore_auth": { - "type": "oauth2", - "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", - "flow": "implicit", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - }, - "api_key": { - "type": "apiKey", - "name": "api_key", - "in": "header" - } - } +{ + "openapi": "3.0.0", + "servers": [], + "info": { + "version": "1.0.9-abcd", + "title": "Swagger Sample API" + }, + "paths": { + "/pets/": { + "get": { + "responses": { + "200": { + "description": "pet response" + } + } + } + } + }, + "components": { + "securitySchemes": { + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + }, + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + } + } } \ No newline at end of file diff --git a/test/Resource/Swagger/Comparison/Modified/misc_checks_01.json b/test/Resource/Swagger/Comparison/Modified/misc_checks_01.json deleted file mode 100644 index 968dbe9..0000000 --- a/test/Resource/Swagger/Comparison/Modified/misc_checks_01.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "misc_checks_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "consumes": [ "text/plain" ], - "produces": [ "text/plain", "text/json" ], - "paths": { - "/api/Parameters": { - "put": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Put", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "database", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/Database" } - } - ] - }, - "post": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Post", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "registry", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/Database" } - } - ] - } - } - }, - "definitions": { - "Database": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "integer", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int64", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/misc_checks_02.json b/test/Resource/Swagger/Comparison/Modified/misc_checks_02.json deleted file mode 100644 index b99f0fc..0000000 --- a/test/Resource/Swagger/Comparison/Modified/misc_checks_02.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "misc_checks_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "definitions": { - "Database": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "integer", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int64", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/operation_check_01.json b/test/Resource/Swagger/Comparison/Modified/operation_check_01.json deleted file mode 100644 index 02e54b5..0000000 --- a/test/Resource/Swagger/Comparison/Modified/operation_check_01.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Path": { - "get": { - "tag": [ "Paths" ], - "operationId": "Paths_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": {} - } - }, - "/api/Operations": { - "put": { - "tag": [ "Operations" ], - "operationId": "Operations_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": {} - }, - "post": { - "tag": [ "Operations" ], - "operationId": "Operations_Port", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": {} - } - }, - "/api/Parameters/{b}": { - "get": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Get", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "b", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "c", - "in": "query", - "required": true, - "type": "string" - }, - { - "name": "d", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "e", - "in": "query", - "required": true, - "type": "string" - }, - { - "name": "f", - "in": "query", - "required": true, - "type": "string", - "enum": [ "theonlyvalue", "andonemore" ] - } - ] - } - }, - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": { - "201": { - "schema": { - "type": "string" - } - }, - "202": { - "schema": { - "type": "string" - } - }, - "400": { - "schema": { - "type": "object", - "properties": { - "message": { "type": "string" }, - "id": { "type": "integer"} - } - } - } - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/operation_check_02.json b/test/Resource/Swagger/Comparison/Modified/operation_check_02.json deleted file mode 100644 index e7c15f5..0000000 --- a/test/Resource/Swagger/Comparison/Modified/operation_check_02.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Parameters": { - "put": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Put", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "database", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/DatabaseRenamed" } - } - ] - }, - "post": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Post", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "registry", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/Register" } - } - ] - } - }, - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": { - "200": { - "schema": { - "type": "integer" - } - }, - "201": { - "schema": { - "type": "integer" - } - }, - "400": { - "schema": { "$ref": "#/definitions/Error" } - } - } - } - } - }, - "definitions": { - "Error": { - "required": [ "message", "id" ], - "properties": { - "message": { "type": "string" }, - "id": { "type": "integer" } - } - }, - "DatabaseRenamed": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - }, - "Register": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "integer", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/operation_check_03.json b/test/Resource/Swagger/Comparison/Modified/operation_check_03.json deleted file mode 100644 index a81398f..0000000 --- a/test/Resource/Swagger/Comparison/Modified/operation_check_03.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_03", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Parameters": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "parameters": [ - { - "name": "x-bo", - "in": "header", - "type": "string", - "required": false - }, - { - "name": "x-br", - "in": "header", - "type": "string", - "required": true - }, - { - "name": "x-co", - "in": "header", - "type": "integer", - "required": false - }, - { - "name": "x-cr", - "in": "header", - "type": "integer", - "required": true - } - - ] - } - }, - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "parameters": [], - "responses": { - "200": { - "headers": { - "x-b": { "type": "string" }, - "x-c": { "type": "integer" } - } - } - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/operation_check_04.json b/test/Resource/Swagger/Comparison/Modified/operation_check_04.json deleted file mode 100644 index d9e6fa5..0000000 --- a/test/Resource/Swagger/Comparison/Modified/operation_check_04.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_04", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Parameters": { - "get": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Get", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "a", - "in": "header", - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - { - "name": "b", - "in": "header", - "type": "array", - "minItems": 15, - "maxItems": 4000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - { - "name": "c", - "in": "header", - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - { - "name": "d", - "in": "header", - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - } - ] - }, - "put": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Put", - "consumes": [ - "application/json" - ], - "parameters": [ - { - "name": "a", - "type": "object", - "in": "body", - "schema": { "$ref": "#/definitions/A" } - } - ] - } - } - }, - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "type": "array", - "minItems": 15, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/operation_check_05.json b/test/Resource/Swagger/Comparison/Modified/operation_check_05.json deleted file mode 100644 index 7d322aa..0000000 --- a/test/Resource/Swagger/Comparison/Modified/operation_check_05.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_05", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": { - "200": { - "schema": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "type": "array", - "minItems": 15, - "maxItems": 4000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - } - } - } - }, - "201": { - "schema": { "$ref": "#/definitions/A" } - } - } - } - } - }, - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "type": "array", - "minItems": 15, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/param_check_01.json b/test/Resource/Swagger/Comparison/Modified/param_check_01.json deleted file mode 100644 index 0f6e65e..0000000 --- a/test/Resource/Swagger/Comparison/Modified/param_check_01.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_04", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "type": "array", - "minItems": 15, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - }, - "f": { - "type": "string", - "enum": [ "A", "B", "C" ] - }, - "g": { - "type": "string", - "enum": [ "A", "B" ] - } - } - } - }, - "parameters": { - "a": { - "name": "a", - "in": "header", - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "name": "b", - "in": "header", - "type": "array", - "minItems": 15, - "maxItems": 4000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "name": "c", - "in": "header", - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "name": "d", - "in": "header", - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - }, - "e": { - "name": "e", - "type": "object", - "in": "body", - "schema": { "$ref": "#/definitions/A" } - }, - "f": { - "type": "string", - "in": "header", - "enum": [ "A", "B", "C" ] - }, - "g": { - "type": "string", - "in": "header", - "enum": [ "A", "B" ] - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/response_check_01.json b/test/Resource/Swagger/Comparison/Modified/response_check_01.json deleted file mode 100644 index 64951b1..0000000 --- a/test/Resource/Swagger/Comparison/Modified/response_check_01.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_05", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "type": "array", - "minItems": 15, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - }, - "f": { - "type": "string", - "enum": [ "A", "B", "C" ] - }, - "g": { - "type": "string", - "enum": [ "A", "B" ] - } - } - } - }, - "responses": { - "200": { - "schema": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 11, - "maxItems": 5000, - "collectionFormat": "pipes", - "items": { - "type": "integer", - "minimum": 11, - "maximum": 21, - "multipleOf": 4 - } - }, - "b": { - "type": "array", - "minItems": 15, - "maxItems": 4000, - "collectionFormat": "pipes", - "items": { - "type": "string", - "minLength": 0, - "maxLength": 15, - "pattern": "[a-z][a-z]*" - } - }, - "c": { - "type": "integer", - "minimum": 0, - "maximum": 15, - "multipleOf": 4 - }, - "d": { - "type": "string", - "minLength": 11, - "maxLength": 21, - "pattern": "[a-z][a-z]*" - }, - "f": { - "type": "string", - "enum": [ "A", "B", "C" ] - }, - "g": { - "type": "string", - "enum": [ "A", "B" ] - } - } - } - }, - "201": { - "schema": { "$ref": "#/definitions/A" } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Modified/version_check_01.json b/test/Resource/Swagger/Comparison/Modified/version_check_01.json deleted file mode 100644 index 8231ed6..0000000 --- a/test/Resource/Swagger/Comparison/Modified/version_check_01.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_01", - "version": "2.0" - }, - "host": "localhost:8000", - "schemes": [ "http" ] -} diff --git a/test/Resource/Swagger/Comparison/Modified/version_check_02.json b/test/Resource/Swagger/Comparison/Modified/version_check_02.json deleted file mode 100644 index fe0d9ef..0000000 --- a/test/Resource/Swagger/Comparison/Modified/version_check_02.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_02", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http" ] -} diff --git a/test/Resource/Swagger/Comparison/Modified/version_check_03.json b/test/Resource/Swagger/Comparison/Modified/version_check_03.json deleted file mode 100644 index 58ff826..0000000 --- a/test/Resource/Swagger/Comparison/Modified/version_check_03.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_03", - "version": "1.1.0" - }, - "host": "localhost:8000", - "schemes": [ "http" ] -} diff --git a/test/Resource/Swagger/Comparison/Modified/version_check_04.json b/test/Resource/Swagger/Comparison/Modified/version_check_04.json deleted file mode 100644 index 2716f8a..0000000 --- a/test/Resource/Swagger/Comparison/Modified/version_check_04.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_04", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http" ] -} diff --git a/test/Resource/Swagger/Comparison/Original/misc_checks_01.json b/test/Resource/Swagger/Comparison/Original/misc_checks_01.json deleted file mode 100644 index d511f9c..0000000 --- a/test/Resource/Swagger/Comparison/Original/misc_checks_01.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "misc_checks_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "consumes": [ "text/plain", "text/json" ], - "produces": [ "text/plain" ], - "paths": { - "/api/Parameters": { - "put": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Put", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "database", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/DatabaseList" } - } - ] - }, - "post": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Post", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "registry", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/Database" } - } - ] - } - } - }, - "definitions": { - "DatabaseList": { - "properties": { - "a": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe _rid value is empty for this operation." - }, - "b": { - "type": "integer", - "readOnly": true, - "default": 0, - "description": "This property shows the number of databases returned." - }, - "c": { - "type": "array", - "readOnly": true, - "description": "A list of databases.", - "items": { "$ref": "#/definitions/Database" } - } - } - }, - "Database": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/misc_checks_02.json b/test/Resource/Swagger/Comparison/Original/misc_checks_02.json deleted file mode 100644 index 6175be2..0000000 --- a/test/Resource/Swagger/Comparison/Original/misc_checks_02.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "misc_checks_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "definitions": { - "Database": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - }, - "Unreferenced": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/operation_check_01.json b/test/Resource/Swagger/Comparison/Original/operation_check_01.json deleted file mode 100644 index ac8360e..0000000 --- a/test/Resource/Swagger/Comparison/Original/operation_check_01.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Paths": { - "get": { - "tag": [ "Paths" ], - "operationId": "Paths_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": {} - } - }, - "/api/Operations": { - "get": { - "tag": [ "Operations" ], - "operationId": "Operations_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": {} - }, - "post": { - "tag": [ "Operations" ], - "operationId": "Operations_Post", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": {} - } - }, - "/api/Parameters/{a}": { - "get": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Get", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "a", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "b", - "in": "query", - "required": true, - "type": "string" - }, - { - "name": "d", - "in": "query", - "required": true, - "type": "string" - }, - { - "name": "e", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "f", - "in": "query", - "required": true, - "type": "string", - "enum": [ "theonlyvalue" ] - } - ] - } - }, - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": { - "200": { - "schema": { - "type": "integer" - } - }, - "201": { - "schema": { - "type": "integer" - } - }, - "400": { - "schema": { - "type": "object", - "properties": { - "message": { "type": "string" }, - "id": { "type": "string" } - } - } - } - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/operation_check_02.json b/test/Resource/Swagger/Comparison/Original/operation_check_02.json deleted file mode 100644 index acd85c2..0000000 --- a/test/Resource/Swagger/Comparison/Original/operation_check_02.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Parameters": { - "put": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Put", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "database", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/Database" } - } - ] - }, - "post": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Post", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "registry", - "in": "body", - "required": true, - "type": "object", - "schema": { "$ref": "#/definitions/Registry" } - } - ] - } - }, - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": { - "200": { - "schema": { - "type": "integer" - } - }, - "201": { - "schema": { - "type": "integer" - } - }, - "400": { - "schema": { "$ref": "#/definitions/Error" } - } - } - } - } - }, - "definitions": { - "Error": { - "required": [ "message", "id" ], - "properties": { - "message": { "type": "string" }, - "id": { "type": "string" } - } - }, - "Database": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - }, - "Registry": { - "required": [ "id" ], - "properties": { - "a": { - "type": "string", - "description": "The user generated unique name for the database, a string that\n must not be more than 255 characters." - }, - "b": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nThe resource id (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement of and navigation to the database resource." - }, - "c": { - "type": "integer", - "format": "int32", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the last updated timestamp of the resource. The value is a timestamp." - }, - "d": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt represents the resource etag required for optimistic concurrency control." - }, - "e": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the collections resource." - }, - "f": { - "type": "string", - "readOnly": true, - "description": "This is a system generated property.\nIt specifies the addressable path of the users resource." - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/operation_check_03.json b/test/Resource/Swagger/Comparison/Original/operation_check_03.json deleted file mode 100644 index 8010804..0000000 --- a/test/Resource/Swagger/Comparison/Original/operation_check_03.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_03", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Parameters": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "parameters": [ - { - "name": "x-ao", - "in": "header", - "type": "integer", - "required": false - }, - { - "name": "x-ar", - "in": "header", - "type": "integer", - "required": true - }, - { - "name": "x-bo", - "in": "header", - "type": "integer", - "required": false - }, - { - "name": "x-br", - "in": "header", - "type": "integer", - "required": true - } - ] - } - }, - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "parameters": [], - "responses": { - "200": { - "headers": { - "x-a": { "type": "integer" }, - "x-b": { "type": "integer" } - } - } - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/operation_check_04.json b/test/Resource/Swagger/Comparison/Original/operation_check_04.json deleted file mode 100644 index 6e21ddf..0000000 --- a/test/Resource/Swagger/Comparison/Original/operation_check_04.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_04", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Parameters": { - "get": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Get", - "produces": [ - "text/plain" - ], - "parameters": [ - { - "name": "a", - "in": "header", - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - { - "name": "b", - "in": "header", - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - { - "name": "c", - "in": "header", - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - { - "name": "d", - "in": "header", - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - ] - }, - "put": { - "tag": [ "Parameters" ], - "operationId": "Parameters_Put", - "consumes": [ - "application/json" - ], - "parameters": [ - { - "name": "a", - "type": "object", - "in": "body", - "schema": { "$ref": "#/definitions/A" } - } - ] - } - } - }, - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/operation_check_05.json b/test/Resource/Swagger/Comparison/Original/operation_check_05.json deleted file mode 100644 index f5ba2ee..0000000 --- a/test/Resource/Swagger/Comparison/Original/operation_check_05.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_05", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "paths": { - "/api/Responses": { - "get": { - "tag": [ "Responses" ], - "operationId": "Responses_Get", - "produces": [ - "text/plain" - ], - "parameters": [], - "responses": { - "200": { - "schema": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - } - } - }, - "201": { - "schema": { "$ref": "#/definitions/A"} - } - } - } - } - }, - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/param_check_01.json b/test/Resource/Swagger/Comparison/Original/param_check_01.json deleted file mode 100644 index 93f0be1..0000000 --- a/test/Resource/Swagger/Comparison/Original/param_check_01.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_04", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - }, - "f": { - "type": "string", - "enum": [ "A", "B" ] - }, - "g": { - "type": "string", - "enum": [ "A", "B", "C" ] - } - } - } - }, - "parameters": { - "a": { - "name": "a", - "in": "header", - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "name": "b", - "in": "header", - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "name": "c", - "in": "header", - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "name": "d", - "in": "header", - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - }, - "e": { - "name": "e", - "type": "object", - "in": "body", - "schema": { "$ref": "#/definitions/A" } - }, - "f": { - "type": "string", - "in": "header", - "enum": [ "A", "B" ] - }, - "g": { - "type": "string", - "in": "header", - "enum": [ "A", "B", "C" ] - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/response_check_01.json b/test/Resource/Swagger/Comparison/Original/response_check_01.json deleted file mode 100644 index b0b80ee..0000000 --- a/test/Resource/Swagger/Comparison/Original/response_check_01.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "operation_check_05", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ], - "definitions": { - "A": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - }, - "f": { - "type": "string", - "enum": [ "A", "B" ] - }, - "g": { - "type": "string", - "enum": [ "A", "B", "C" ] - } - } - } - }, - "responses": { - "200": { - "schema": { - "type": "object", - "properties": { - "a": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - } - }, - "b": { - "type": "array", - "minItems": 13, - "maxItems": 4711, - "collectionFormat": "csv", - "items": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - } - }, - "c": { - "type": "integer", - "minimum": 1, - "maximum": 17, - "multipleOf": 5 - }, - "d": { - "type": "string", - "minLength": 1, - "maxLength": 17, - "pattern": "[a-z][a-z0-9]*" - }, - "f": { - "type": "string", - "enum": [ "A", "B" ] - }, - "g": { - "type": "string", - "enum": [ "A", "B", "C" ] - } - } - } - }, - "201": { - "schema": { "$ref": "#/definitions/A" } - } - } -} diff --git a/test/Resource/Swagger/Comparison/Original/version_check_01.json b/test/Resource/Swagger/Comparison/Original/version_check_01.json deleted file mode 100644 index 6629990..0000000 --- a/test/Resource/Swagger/Comparison/Original/version_check_01.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_01", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ] -} diff --git a/test/Resource/Swagger/Comparison/Original/version_check_02.json b/test/Resource/Swagger/Comparison/Original/version_check_02.json deleted file mode 100644 index 54dc993..0000000 --- a/test/Resource/Swagger/Comparison/Original/version_check_02.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_02", - "version": "1.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ] -} diff --git a/test/Resource/Swagger/Comparison/Original/version_check_03.json b/test/Resource/Swagger/Comparison/Original/version_check_03.json deleted file mode 100644 index 9813b8b..0000000 --- a/test/Resource/Swagger/Comparison/Original/version_check_03.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_03", - "version": "1.0.0" - }, - "host": "localhost:8000", - "schemes": [ "http", "https" ] -} diff --git a/test/Resource/Swagger/Comparison/Original/version_check_04.json b/test/Resource/Swagger/Comparison/Original/version_check_04.json deleted file mode 100644 index c469931..0000000 --- a/test/Resource/Swagger/Comparison/Original/version_check_04.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "swagger": 2.0, - "info": { - "title": "version_check_04", - "version": "2.0" - }, - "host": "localhost:8000", - "schemes": [ "http" ] -} diff --git a/test/Resource/Swagger/arm-network/2016-09-01/swagger/applicationGateway.json b/test/Resource/Swagger/arm-network/2016-09-01/swagger/applicationGateway.json deleted file mode 100644 index f1cf2af..0000000 --- a/test/Resource/Swagger/arm-network/2016-09-01/swagger/applicationGateway.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "NetworkManagementClient", - "description": "The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.", - "version": "2016-09-01" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": {}, - "definitions": { - "ApplicationGatewayBackendAddressPool": { - "properties": { - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/ApplicationGatewayBackendAddressPoolPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Resource that is unique within a resource group. This name can be used to access the resource." - }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated." - } - }, - "description": "Backend Address Pool of an application gateway." - }, - "ApplicationGatewayBackendAddressPoolPropertiesFormat": { - "properties": { - "backendIPConfigurations": { - "type": "array", - "items": { - "$ref": "./networkInterface.json#/definitions/NetworkInterfaceIPConfiguration" - }, - "description": "Collection of references to IPs defined in network interfaces." - }, - "backendAddresses": { - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationGatewayBackendAddress" - }, - "description": "Backend addresses" - }, - "provisioningState": { - "type": "string", - "description": "Provisioning state of the backend address pool resource. Possible values are: 'Updating', 'Deleting', and 'Failed'." - } - }, - "description": "Properties of Backend Address Pool of an application gateway." - } - }, - "parameters": { - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." - }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client API version." - } - } -} diff --git a/test/Resource/Swagger/arm-network/2016-09-01/swagger/networkInterface.json b/test/Resource/Swagger/arm-network/2016-09-01/swagger/networkInterface.json index 5bb8791..4644729 100644 --- a/test/Resource/Swagger/arm-network/2016-09-01/swagger/networkInterface.json +++ b/test/Resource/Swagger/arm-network/2016-09-01/swagger/networkInterface.json @@ -1,22 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "NetworkManagementClient", "description": "The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.", "version": "2016-09-01" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], "security": [ { "azure_auth": [ @@ -24,63 +17,72 @@ ] } ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, "paths": {}, - "definitions": { - "NetworkInterfaceIPConfiguration": { - "properties": { + "components": { + "schemas": { + "NetworkInterfaceIPConfiguration": { "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/NetworkInterfaceIPConfigurationPropertiesFormat" - }, - "name": { - "type": "string", - "description": "The name of the resource that is unique within a resource group. This name can be used to access the resource." + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/components/schemas/NetworkInterfaceIPConfigurationPropertiesFormat" + }, + "name": { + "type": "string", + "description": "The name of the resource that is unique within a resource group. This name can be used to access the resource." + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated." + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated." - } + "description": "IPConfiguration in a network interface." }, - "description": "IPConfiguration in a network interface." + "NetworkInterfaceIPConfigurationPropertiesFormat": { + "properties": { + "applicationGatewayBackendAddressPools": { + "type": "array", + "items": { + "$ref": "./applicationGateway.json#/definitions/ApplicationGatewayBackendAddressPool" + }, + "description": "The reference of ApplicationGatewayBackendAddressPool resource." + } + }, + "description": "Properties of IP configuration." + } }, - "NetworkInterfaceIPConfigurationPropertiesFormat": { - "properties": { - "applicationGatewayBackendAddressPools": { - "type": "array", - "items": { - "$ref": "./applicationGateway.json#/definitions/ApplicationGatewayBackendAddressPool" - }, - "description": "The reference of ApplicationGatewayBackendAddressPool resource." + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "schema": { + "type": "string" } }, - "description": "Properties of IP configuration." - } - }, - "parameters": { - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "description": "Client API version.", + "schema": { + "type": "string" + } + } }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client API version." + "securitySchemes": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow", + "flows": { + "implicit": { + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + } + } } } } \ No newline at end of file diff --git a/test/Resource/Swagger/arm-network/2016-12-01/swagger/applicationGateway.json b/test/Resource/Swagger/arm-network/2016-12-01/swagger/applicationGateway.json index a06b44c..29bbb69 100644 --- a/test/Resource/Swagger/arm-network/2016-12-01/swagger/applicationGateway.json +++ b/test/Resource/Swagger/arm-network/2016-12-01/swagger/applicationGateway.json @@ -1,22 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "NetworkManagementClient", "description": "The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.", "version": "2016-12-01" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], "security": [ { "azure_auth": [ @@ -24,128 +17,137 @@ ] } ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, "paths": {}, - "definitions": { - "ApplicationGatewayBackendHealth": { - "properties": { - "backendAddressPools": { - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationGatewayBackendHealthPool" + "components": { + "schemas": { + "ApplicationGatewayBackendHealth": { + "properties": { + "backendAddressPools": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ApplicationGatewayBackendHealthPool" + } } - } - }, - "description": "List of ApplicationGatewayBackendHealthPool resources." - }, - "ApplicationGatewayBackendHealthPool": { - "properties": { - "backendAddressPool": { - "$ref": "#/definitions/ApplicationGatewayBackendAddressPool", - "description": "Reference of an ApplicationGatewayBackendAddressPool resource." - } + }, + "description": "List of ApplicationGatewayBackendHealthPool resources." }, - "description": "Application gateway BackendHealth pool." - }, - "ApplicationGatewayBackendAddress": { - "properties": { - "fqdn": { - "type": "string", - "description": "Fully qualified domain name (FQDN)." + "ApplicationGatewayBackendHealthPool": { + "properties": { + "backendAddressPool": { + "$ref": "#/components/schemas/ApplicationGatewayBackendAddressPool", + "description": "Reference of an ApplicationGatewayBackendAddressPool resource." + } }, - "ipAddress": { - "type": "string", - "description": "IP address" - } + "description": "Application gateway BackendHealth pool." }, - "description": "Backend address of an application gateway." - }, - "ApplicationGatewayBackendAddressPoolPropertiesFormat": { - "properties": { - "backendIPConfigurations": { - "type": "array", - "items": { - "$ref": "./../../2016-09-01/swagger/networkInterface.json#/definitions/NetworkInterfaceIPConfiguration" + "ApplicationGatewayBackendAddress": { + "properties": { + "fqdn": { + "type": "string", + "description": "Fully qualified domain name (FQDN)." }, - "description": "Collection of references to IPs defined in network interfaces." + "ipAddress": { + "type": "string", + "description": "IP address" + } }, - "backendAddresses": { - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationGatewayBackendAddress" + "description": "Backend address of an application gateway." + }, + "ApplicationGatewayBackendAddressPoolPropertiesFormat": { + "properties": { + "backendIPConfigurations": { + "type": "array", + "items": { + "$ref": "./../../2016-09-01/swagger/networkInterface.json#/definitions/NetworkInterfaceIPConfiguration" + }, + "description": "Collection of references to IPs defined in network interfaces." + }, + "backendAddresses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ApplicationGatewayBackendAddress" + }, + "description": "Backend addresses" }, - "description": "Backend addresses" + "provisioningState": { + "type": "string", + "description": "Provisioning state of the backend address pool resource. Possible values are: 'Updating', 'Deleting', and 'Failed'." + } }, - "provisioningState": { - "type": "string", - "description": "Provisioning state of the backend address pool resource. Possible values are: 'Updating', 'Deleting', and 'Failed'." - } + "description": "Properties of Backend Address Pool of an application gateway." }, - "description": "Properties of Backend Address Pool of an application gateway." - }, - "ApplicationGatewayBackendAddressPool": { - "properties": { + "ApplicationGatewayBackendAddressPool": { "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/ApplicationGatewayBackendAddressPoolPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Resource that is unique within a resource group. This name can be used to access the resource." + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/components/schemas/ApplicationGatewayBackendAddressPoolPropertiesFormat" + }, + "name": { + "type": "string", + "description": "Resource that is unique within a resource group. This name can be used to access the resource." + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated." + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated." - } + "allOf": [ + { + "$ref": "./network.json#/definitions/SubResource" + } + ], + "description": "Backend Address Pool of an application gateway." }, - "allOf": [ - { - "$ref": "./network.json#/definitions/SubResource" + "FooBarPool": { + "description": "It is a foo bar pool.", + "properties": { + "properties": { + "$ref": "#/components/schemas/FooBarPoolProperties" + } } - ], - "description": "Backend Address Pool of an application gateway." - }, - "FooBarPool": { - "description": "It is a foo bar pool.", - "properties": { + }, + "FooBarPoolProperties": { + "description": "It is a foo bar pool.", "properties": { - "$ref": "#/definitions/FooBarPoolProperties" + "resProp1": { + "$ref": "./network.json#/definitions/FooResource" + } } } }, - "FooBarPoolProperties": { - "description": "It is a foo bar pool.", - "properties": { - "resProp1": { - "$ref": "./network.json#/definitions/FooResource" + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "schema": { + "type": "string" + } + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "description": "Client API version.", + "schema": { + "type": "string" } } - } - }, - "parameters": { - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client API version." + "securitySchemes": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow", + "flows": { + "implicit": { + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + } + } } } } \ No newline at end of file diff --git a/test/Resource/Swagger/arm-network/2016-12-01/swagger/network.json b/test/Resource/Swagger/arm-network/2016-12-01/swagger/network.json index d835eb1..5576909 100644 --- a/test/Resource/Swagger/arm-network/2016-12-01/swagger/network.json +++ b/test/Resource/Swagger/arm-network/2016-12-01/swagger/network.json @@ -1,22 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "NetworkManagementClient", "description": "The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.", "version": "2016-12-01" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], "security": [ { "azure_auth": [ @@ -24,138 +17,146 @@ ] } ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - }, - "definitions": { - "ErrorDetails": { - "properties": { - "code": { - "type": "string" - }, - "target": { - "type": "string" - }, - "message": { - "type": "string" - } - } - }, - "Error": { - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "target": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "$ref": "#/definitions/ErrorDetails" + "paths": {}, + "components": { + "schemas": { + "ErrorDetails": { + "properties": { + "code": { + "type": "string" + }, + "target": { + "type": "string" + }, + "message": { + "type": "string" } - }, - "innerError": { - "type": "string" } - } - }, - "AzureAsyncOperationResult": { - "properties": { - "status": { - "type": "string", - "description": "Status of the Azure async operation. Possible values are: 'InProgress', 'Succeeded', and 'Failed'.", - "enum": [ - "InProgress", - "Succeeded", - "Failed" - ], - "x-ms-enum": { - "name": "NetworkOperationStatus", - "modelAsString": true + }, + "Error": { + "properties": { + "code": { + "type": "string" + }, + "message": { + "type": "string" + }, + "target": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorDetails" + } + }, + "innerError": { + "type": "string" } - }, - "error": { - "$ref": "#/definitions/Error" } }, - "description": "The response body contains the status of the specified asynchronous operation, indicating whether it has succeeded, is in progress, or has failed. Note that this status is distinct from the HTTP status code returned for the Get Operation Status operation itself. If the asynchronous operation succeeded, the response body includes the HTTP status code for the successful request. If the asynchronous operation failed, the response body includes the HTTP status code for the failed request and error information regarding the failure." - }, - "Resource": { - "properties": { - "id": { - "type": "string", - "description": "Resource ID." - }, - "name": { - "readOnly": true, - "type": "string", - "description": "Resource name." + "AzureAsyncOperationResult": { + "properties": { + "status": { + "type": "string", + "description": "Status of the Azure async operation. Possible values are: 'InProgress', 'Succeeded', and 'Failed'.", + "enum": [ + "InProgress", + "Succeeded", + "Failed" + ], + "x-ms-enum": { + "name": "NetworkOperationStatus", + "modelAsString": true + } + }, + "error": { + "$ref": "#/components/schemas/Error" + } }, - "type": { - "readOnly": true, - "type": "string", - "description": "Resource type." + "description": "The response body contains the status of the specified asynchronous operation, indicating whether it has succeeded, is in progress, or has failed. Note that this status is distinct from the HTTP status code returned for the Get Operation Status operation itself. If the asynchronous operation succeeded, the response body includes the HTTP status code for the successful request. If the asynchronous operation failed, the response body includes the HTTP status code for the failed request and error information regarding the failure." + }, + "Resource": { + "properties": { + "id": { + "type": "string", + "description": "Resource ID." + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name." + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type." + }, + "location": { + "type": "string", + "description": "Resource location." + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags." + } }, - "location": { - "type": "string", - "description": "Resource location." + "x-ms-azure-resource": true + }, + "SubResource": { + "properties": { + "id": { + "type": "string", + "description": "Resource ID." + } }, - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Resource tags." - } + "x-ms-azure-resource": true }, - "x-ms-azure-resource": true + "FooResource": { + "description": "It is a foo bar pool.", + "properties": { + "poolProp1": { + "$ref": "./applicationGateway.json#/definitions/FooBarPool" + } + } + } }, - "SubResource": { - "properties": { - "id": { - "type": "string", - "description": "Resource ID." + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "schema": { + "type": "string" } }, - "x-ms-azure-resource": true - }, - "FooResource": { - "description": "It is a foo bar pool.", - "properties": { - "poolProp1": { - "$ref": "./applicationGateway.json#/definitions/FooBarPool" + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "description": "Client API version.", + "schema": { + "type": "string" } } - } - }, - "parameters": { - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client API version." + "securitySchemes": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow", + "flows": { + "implicit": { + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + } + } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-additional-properties.yaml b/test/Resource/Swagger/swagger-additional-properties.yaml index 7a93d78..b493250 100644 --- a/test/Resource/Swagger/swagger-additional-properties.yaml +++ b/test/Resource/Swagger/swagger-additional-properties.yaml @@ -1,122 +1,182 @@ -swagger: '2.0' -info: - version: 1.0.0 - title: PetStore on Heroku - description: | - **This example has a working backend hosted in Heroku** - - You can try all HTTP operation described in this Swagger spec. - - Find source code of this API [here](https://github.com/mohsen1/petstore-api) -host: petstore-api.herokuapp.com -basePath: /pet -schemes: - - http - - https -consumes: - - application/json - - text/xml -produces: - - application/json - - text/html -paths: - /: - get: - operationId: get_pets - parameters: - - name: limit - in: query - description: number of pets to return - type: integer - default: 11 - minimum: 11 - maximum: 10000 - responses: - 200: - description: List all pets - schema: - title: Pets - type: array - items: - $ref: '#/definitions/Pet' - post: - operationId: post_pets - parameters: - - name: pet - in: body - description: The pet JSON you want to post - schema: - $ref: '#/definitions/Pet' - required: true - responses: - 200: - description: Make a new pet - put: - operationId: put_pets - parameters: - - name: pet - in: body - description: The pet JSON you want to post - schema: - $ref: '#/definitions/Pet' - required: true - responses: - 200: - description: Updates the pet - -definitions: - Pet: - type: object - additionalProperties: - type: object - $ref: '#/definitions/Feature' - - properties: - name: - type: string - birthday: - type: integer - format: int32 - wsd: - type: object - $ref: '#/definitions/WithStringDictionary' - wud: - type: object - $ref: '#/definitions/WithUntypedDictionary' - wtd: - type: object - $ref: '#/definitions/WithTypedDictionary' - - Feature: - type: object - properties: - foo: - type: string - bar: - type: integer - format: int32 - - WithStringDictionary: - type: object - properties: - abc: - type: string - additionalProperties: - type: string - - WithUntypedDictionary: - properties: - abc: - type: string - type: object - additionalProperties: - type: object - - WithTypedDictionary: - type: object - properties: - abc: - type: string - additionalProperties: - type: object - $ref: '#/definitions/Feature' +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://petstore-api.herokuapp.com/pet" + }, + { + "url": "https://petstore-api.herokuapp.com/pet" + } + ], + "info": { + "version": "1.0.0", + "title": "PetStore on Heroku", + "description": "**This example has a working backend hosted in Heroku**\n\nYou can try all HTTP operation described in this Swagger spec.\n\nFind source code of this API [here](https://github.com/mohsen1/petstore-api)\n" + }, + "paths": { + "/": { + "get": { + "operationId": "get_pets", + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "number of pets to return", + "schema": { + "type": "integer", + "minimum": 11, + "maximum": 10000, + "default": 11 + } + } + ], + "responses": { + "200": { + "description": "List all pets", + "content": { + "application/json": { + "schema": { + "title": "Pets", + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "text/html": { + "schema": { + "title": "Pets", + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + } + }, + "post": { + "operationId": "post_pets", + "responses": { + "200": { + "description": "Make a new pet" + } + }, + "requestBody": { + "$ref": "#/components/requestBodies/Pet" + }, + "x-ms-requestBody-index": 0 + }, + "put": { + "operationId": "put_pets", + "responses": { + "200": { + "description": "Updates the pet" + } + }, + "requestBody": { + "$ref": "#/components/requestBodies/Pet" + }, + "x-ms-requestBody-index": 0 + } + } + }, + "components": { + "schemas": { + "Pet": { + "type": "object", + "additionalProperties": { + "type": "object", + "$ref": "#/components/schemas/Feature" + }, + "properties": { + "name": { + "type": "string" + }, + "birthday": { + "type": "integer", + "format": "int32" + }, + "wsd": { + "type": "object", + "$ref": "#/components/schemas/WithStringDictionary" + }, + "wud": { + "type": "object", + "$ref": "#/components/schemas/WithUntypedDictionary" + }, + "wtd": { + "type": "object", + "$ref": "#/components/schemas/WithTypedDictionary" + } + } + }, + "Feature": { + "type": "object", + "properties": { + "foo": { + "type": "string" + }, + "bar": { + "type": "integer", + "format": "int32" + } + } + }, + "WithStringDictionary": { + "type": "object", + "properties": { + "abc": { + "type": "string" + } + }, + "additionalProperties": { + "type": "string" + } + }, + "WithUntypedDictionary": { + "properties": { + "abc": { + "type": "string" + } + }, + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "WithTypedDictionary": { + "type": "object", + "properties": { + "abc": { + "type": "string" + } + }, + "additionalProperties": { + "type": "object", + "$ref": "#/components/schemas/Feature" + } + } + }, + "requestBodies": { + "Pet": { + "x-ms-client-name": "pet", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "description": "The pet JSON you want to post", + "required": true + } + } + } +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-allOf-circular.json b/test/Resource/Swagger/swagger-allOf-circular.json index 5bbfa81..8284c76 100644 --- a/test/Resource/Swagger/swagger-allOf-circular.json +++ b/test/Resource/Swagger/swagger-allOf-circular.json @@ -1,340 +1,858 @@ - { - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Wordnik API Team", - "email": "foo@example.com", - "url": "http://madskristensen.net" - }, - "license": { - "name": "MIT", - "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" - } + "openapi": "3.0.0", + "servers": [ + { + "url": "http://petstore.swagger.wordnik.com/api" + }, + { + "url": "https://petstore.swagger.wordnik.com/api" + } + ], + "info": { + "version": "1.0.0", + "title": "Swagger Petstore", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Wordnik API Team", + "email": "foo@example.com", + "url": "http://madskristensen.net" }, - "host": "petstore.swagger.wordnik.com", - "basePath": "/api", - "schemes": [ - "http", - "https" - ], - "consumes": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/octet-stream", - "application/zip", - "application/gzip" - ], - "produces": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/atom+xml; charset=utf-8", - "application/octet-stream", - "application/zip", - "application/gzip" - ], - "paths": { - "/pet": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "required": false, - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/pet" - } - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } + "license": { + "name": "MIT", + "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" + } + }, + "paths": { + "/pet": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "required": false, + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/newPet" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } } - }, - "put": { - "tags": [ ], - "summary": "", - "description": "", - "operationId": "CreateOrUpdatePet", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], - "responses": { - "200": { "$ref": "#/responses/petResponse" }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } - }, - "schemes": [ "http", "https" ], - "deprecated": true, - "security": [], - "x-test-header-info": { "name": "x-static-header", "value": "headerValue" } + }, + "text/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/html": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/json; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/octet-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/zip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/gzip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + } } - }, - "/pet/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" - } - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "default": { - "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" } + } } + } } - }, - "definitions": { - "pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } - }, - "cat": { - "allOf": [ - {"$ref": "#/definitions/pet"}, - {"required": [ "breed"], - "properties": { - "breed": { - "type": "string" - }, - "color": { - "type": "string" - } - } - } - ] - }, - "siamese": { - "allOf": [{"$ref": "#/definitions/siamese"}], - "properties": { - "mood": { - "type": "string" + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + }, + "requestBody": { + "x-ms-client-name": "pet", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } } + }, + "description": "Pet to add to the store", + "required": true }, - "dog": { - "allOf": [ {"$ref": "#/definitions/newPet"}], - "required": [ "pedigree"], - "properties": { - "pedigree": { - "type": "boolean" + "x-ms-requestBody-index": 0 + }, + "put": { + "tags": [], + "summary": "", + "description": "", + "operationId": "CreateOrUpdatePet", + "responses": { + "200": { + "$ref": "#/components/responses/petResponse" + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } + } }, - "newPet": { - "allOf": [ - { - "$ref": "#/definitions/dog" - }, - { - "required": [ - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - } - } - } - ] + "deprecated": true, + "security": [], + "x-test-header-info": { + "name": "x-static-header", + "value": "headerValue" }, - "errorModel": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" + "requestBody": { + "x-ms-client-name": "PetCreateOrUpdateParameter", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + }, + "description": "A Pet", + "required": true + }, + "x-ms-requestBody-index": 0 + } + }, + "/pet/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + } + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } + } } - }, - "parameters": { - "petParameter": { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", "required": true, "schema": { - "$ref": "#/definitions/pet" + "type": "integer", + "format": "int64" } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "default": { + "description": "unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + } + }, + "security": [], + "tags": [], + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "cat": { + "allOf": [ + { + "$ref": "#/components/schemas/pet" + }, + { + "required": [ + "breed" + ], + "properties": { + "breed": { + "type": "string" + }, + "color": { + "type": "string" + } + } + } + ] + }, + "siamese": { + "allOf": [ + { + "$ref": "#/components/schemas/siamese" + } + ], + "properties": { + "mood": { + "type": "string" + } + } + }, + "dog": { + "allOf": [ + { + "$ref": "#/components/schemas/newPet" + } + ], + "required": [ + "pedigree" + ], + "properties": { + "pedigree": { + "type": "boolean" + } } + }, + "newPet": { + "allOf": [ + { + "$ref": "#/components/schemas/dog" + }, + { + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + ] + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } }, "responses": { - "petResponse": { - "description": " A created or updated pet", + "petResponse": { + "description": " A created or updated pet", + "headers": { + "x-ms-request-id": { + "description": " The request ID", "schema": { - "$ref": "#/definitions/pet" - }, - "headers": { - "x-ms-request-id": { - "description": " The request ID", - "type": "string" - } + "type": "string" } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } - }, - "securityDefinitions": { }, - "security": [ ], - "tags": [ ] + } + } + } } \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-allOf.json b/test/Resource/Swagger/swagger-allOf.json index fd285b0..23eecae 100644 --- a/test/Resource/Swagger/swagger-allOf.json +++ b/test/Resource/Swagger/swagger-allOf.json @@ -1,5 +1,13 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "http://petstore.swagger.wordnik.com/api" + }, + { + "url": "https://petstore.swagger.wordnik.com/api" + } + ], "info": { "version": "1.0.0", "title": "Swagger Petstore", @@ -15,79 +23,189 @@ "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" } }, - "host": "petstore.swagger.wordnik.com", - "basePath": "/api", - "schemes": [ - "http", "https" - ], - "consumes": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/octet-stream", - "application/zip", - "application/gzip" - ], - "produces": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/atom+xml; charset=utf-8", - "application/octet-stream", - "application/zip", - "application/gzip" - ], "paths": { "/pet": { "x-ms-internal": true, "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, - "type": "integer", - "format": "int32" + "schema": { + "type": "integer", + "format": "int32" + } } ], "responses": { "200": { "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/html": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/json; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/octet-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/zip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/gzip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } } @@ -95,106 +213,408 @@ "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/newPet" - } - } - ], "responses": { "200": { "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "pet", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } + }, + "description": "Pet to add to the store", + "required": true + }, + "x-ms-requestBody-index": 0 }, "put": { "tags": [], "summary": "", "description": "", "operationId": "CreateOrUpdatePet", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], "responses": { - "200": { "$ref": "#/responses/petResponse" }, + "200": { + "$ref": "#/components/responses/petResponse" + }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } }, - "schemes": [ "http", "https" ], "deprecated": true, "security": [], "x-test-header-info": { "name": "x-static-header", "value": "headerValue" - } + }, + "requestBody": { + "x-ms-client-name": "PetCreateOrUpdateParameter", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + }, + "description": "A Pet", + "required": true + }, + "x-ms-requestBody-index": 0 } }, "/pet/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to fetch", "required": true, - "type": "integer", - "format": "int64" + "schema": { + "type": "integer", + "format": "int64" + } } ], "responses": { "200": { "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } } @@ -208,8 +628,10 @@ "in": "path", "description": "ID of pet to delete", "required": true, - "type": "integer", - "format": "int64" + "schema": { + "type": "integer", + "format": "int64" + } } ], "responses": { @@ -218,36 +640,89 @@ }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } } } } }, - "definitions": { - "pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" + "security": [], + "tags": [], + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } } - } - }, - "cat": { - "allOf": [ { "$ref": "#/definitions/pet" } ], - "required": [ "breed" ], + }, + "cat": { + "allOf": [ + { + "$ref": "#/components/schemas/pet" + } + ], + "required": [ + "breed" + ], "properties": { "breed": { "type": "string" @@ -256,84 +731,127 @@ "type": "string" } } - }, - "siamese": { - "allOf": [ { "$ref": "#/definitions/cat" } ], - "properties": { - "mood": { - "type": "string" + }, + "siamese": { + "allOf": [ + { + "$ref": "#/components/schemas/cat" + } + ], + "properties": { + "mood": { + "type": "string" + } } - } - }, - "dog": { - "allOf": [ { "$ref": "#/definitions/pet" } ], - "required": [ "pedigree" ], - "properties": { - "pedigree": { - "type": "boolean" + }, + "dog": { + "allOf": [ + { + "$ref": "#/components/schemas/pet" + } + ], + "required": [ + "pedigree" + ], + "properties": { + "pedigree": { + "type": "boolean" + } } - } - }, - "newPet": { - "allOf": [ - { - "$ref": "#/definitions/pet" - }, - { - "required": [ - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" + }, + "newPet": { + "allOf": [ + { + "$ref": "#/components/schemas/pet" + }, + { + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } } } + ] + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } } - ] + } }, - "errorModel": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" + "responses": { + "petResponse": { + "description": " A created or updated pet", + "headers": { + "x-ms-request-id": { + "description": " The request ID", + "schema": { + "type": "string" + } + } }, - "message": { - "type": "string" - } - } - } - }, - "parameters": { - "petParameter": { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - }, - "responses": { - "petResponse": { - "description": " A created or updated pet", - "schema": { - "$ref": "#/definitions/pet" - }, - "headers": { - "x-ms-request-id": { - "description": " The request ID", - "type": "string" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } } } - }, - "securityDefinitions": { }, - "security": [ ], - "tags": [ ] -} + } +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-composite-constants.json b/test/Resource/Swagger/swagger-composite-constants.json index f9b7a37..ed2f951 100644 --- a/test/Resource/Swagger/swagger-composite-constants.json +++ b/test/Resource/Swagger/swagger-composite-constants.json @@ -1,956 +1,952 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "NetworkManagementClient", "description": "The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resrources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.", "version": "2015-06-15" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], - "definitions": { - "FrontendIPConfigurationPropertiesFormat": { - "properties": { - "inboundNatRules": { - "type": "array", - "items": { - "$ref": "#/definitions/SubResource" - }, - "description": "Read only.Inbound rules URIs that use this frontend IP" - }, - "inboundNatPools": { - "type": "array", - "items": { - "$ref": "#/definitions/SubResource" + "paths": {}, + "components": { + "schemas": { + "FrontendIPConfigurationPropertiesFormat": { + "properties": { + "inboundNatRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SubResource" + }, + "description": "Read only.Inbound rules URIs that use this frontend IP" }, - "description": "Read only.Inbound pools URIs that use this frontend IP" - }, - "outboundNatRules": { - "type": "array", - "items": { - "$ref": "#/definitions/SubResource" + "inboundNatPools": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SubResource" + }, + "description": "Read only.Inbound pools URIs that use this frontend IP" }, - "description": "Read only.Outbound rules URIs that use this frontend IP" - }, - "loadBalancingRules": { - "type": "array", - "items": { - "$ref": "#/definitions/SubResource" + "outboundNatRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SubResource" + }, + "description": "Read only.Outbound rules URIs that use this frontend IP" }, - "description": "Gets Load Balancing rules URIs that use this frontend IP" - }, - "privateIPAddress": { - "type": "string", - "description": "Gets or sets the privateIPAddress of the IP Configuration" - }, - "privateIPAllocationMethod": { - "type": "string", - "description": "Gets or sets PrivateIP allocation method (Static/Dynamic)", - "enum": [ - "Static", - "Dynamic" - ], - "x-ms-enum": { - "name": "IPAllocationMethod", - "modelAsString": true + "loadBalancingRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SubResource" + }, + "description": "Gets Load Balancing rules URIs that use this frontend IP" + }, + "privateIPAddress": { + "type": "string", + "description": "Gets or sets the privateIPAddress of the IP Configuration" + }, + "privateIPAllocationMethod": { + "type": "string", + "description": "Gets or sets PrivateIP allocation method (Static/Dynamic)", + "enum": [ + "Static", + "Dynamic" + ], + "x-ms-enum": { + "name": "IPAllocationMethod", + "modelAsString": true + } + }, + "subnet": { + "$ref": "#/components/schemas/Subnet", + "description": "Gets or sets the reference of the subnet resource" + }, + "publicIPAddress": { + "$ref": "#/components/schemas/PublicIPAddress", + "description": "Gets or sets the reference of the PublicIP resource" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "subnet": { - "$ref": "#/definitions/Subnet", - "description": "Gets or sets the reference of the subnet resource" - }, - "publicIPAddress": { - "$ref": "#/definitions/PublicIPAddress", - "description": "Gets or sets the reference of the PublicIP resource" - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "description": "Properties of Frontend IP Configuration of the load balancer" }, - "description": "Properties of Frontend IP Configuration of the load balancer" - }, - "FrontendIPConfiguration": { - "properties": { + "FrontendIPConfiguration": { "properties": { - "$ref": "#/definitions/FrontendIPConfigurationPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } - }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Frontend IP address of the load balancer" - }, - "BackendAddressPoolPropertiesFormat": { - "properties": { - "backendIPConfigurations": { - "type": "array", - "items": { - "$ref": "#/definitions/NetworkInterfaceIPConfiguration" - }, - "description": "Gets collection of references to IPs defined in NICs" - }, - "loadBalancingRules": { - "type": "array", - "items": { - "$ref": "#/definitions/SubResource" + "properties": { + "$ref": "#/components/schemas/FrontendIPConfigurationPropertiesFormat" }, - "description": "Gets Load Balancing rules that use this Backend Address Pool" - }, - "outboundNatRule": { - "$ref": "#/definitions/SubResource", - "description": "Gets outbound rules that use this Backend Address Pool" + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "provisioningState": { - "type": "string", - "description": "Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Frontend IP address of the load balancer" }, - "description": "Properties of BackendAddressPool" - }, - "BackendAddressPool": { - "properties": { + "BackendAddressPoolPropertiesFormat": { "properties": { - "$ref": "#/definitions/BackendAddressPoolPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } - }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Pool of backend IP addresseses" - }, - "InboundNatRulePropertiesFormat": { - "properties": { - "frontendIPConfiguration": { - "$ref": "#/definitions/SubResource", - "description": "Gets or sets a reference to frontend IP Addresses" - }, - "backendIPConfiguration": { - "$ref": "#/definitions/NetworkInterfaceIPConfiguration", - "description": "Gets or sets a reference to a private ip address defined on a NetworkInterface of a VM. Traffic sent to frontendPort of each of the frontendIPConfigurations is forwarded to the backed IP" - }, - "protocol": { - "type": "string", - "description": "Gets or sets the transport potocol for the external endpoint. Possible values are Udp or Tcp", - "enum": [ - "Udp", - "Tcp" - ], - "x-ms-enum": { - "name": "TransportProtocol", - "modelAsString": true + "backendIPConfigurations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NetworkInterfaceIPConfiguration" + }, + "description": "Gets collection of references to IPs defined in NICs" + }, + "loadBalancingRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SubResource" + }, + "description": "Gets Load Balancing rules that use this Backend Address Pool" + }, + "outboundNatRule": { + "$ref": "#/components/schemas/SubResource", + "description": "Gets outbound rules that use this Backend Address Pool" + }, + "provisioningState": { + "type": "string", + "description": "Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "frontendPort": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the port for the external endpoint. You can spcify any port number you choose, but the port numbers specified for each role in the service must be unique. Possible values range between 1 and 65535, inclusive" - }, - "backendPort": { - "type": "integer", - "format": "int32", - "description": "Gets or sets a port used for internal connections on the endpoint. The localPort attribute maps the eternal port of the endpoint to an internal port on a role. This is useful in scenarios where a role must communicate to an internal compotnent on a port that is different from the one that is exposed externally. If not specified, the value of localPort is the same as the port attribute. Set the value of localPort to '*' to automatically assign an unallocated port that is discoverable using the runtime API" - }, - "idleTimeoutInMinutes": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the timeout for the Tcp idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This emlement is only used when the protocol is set to Tcp" - }, - "enableFloatingIP": { - "type": "boolean", - "description": "Configures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn availability Group. This setting is required when using the SQL Always ON availability Groups in SQL server. This setting can't be changed after you create the endpoint" - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "description": "Properties of BackendAddressPool" }, - "description": "Properties of Inbound NAT rule" - }, - "InboundNatRule": { - "properties": { + "BackendAddressPool": { "properties": { - "$ref": "#/definitions/InboundNatRulePropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "properties": { + "$ref": "#/components/schemas/BackendAddressPoolPropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Pool of backend IP addresseses" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Inbound NAT rule of the loadbalancer" - }, - "InboundNatPoolPropertiesFormat": { - "properties": { - "frontendIPConfiguration": { - "$ref": "#/definitions/SubResource", - "description": "Gets or sets a reference to frontend IP Addresses" - }, - "protocol": { - "type": "string", - "description": "Gets or sets the transport potocol for the external endpoint. Possible values are Udp or Tcp", - "enum": [ - "Udp", - "Tcp" - ], - "x-ms-enum": { - "name": "TransportProtocol", - "modelAsString": true + "InboundNatRulePropertiesFormat": { + "properties": { + "frontendIPConfiguration": { + "$ref": "#/components/schemas/SubResource", + "description": "Gets or sets a reference to frontend IP Addresses" + }, + "backendIPConfiguration": { + "$ref": "#/components/schemas/NetworkInterfaceIPConfiguration", + "description": "Gets or sets a reference to a private ip address defined on a NetworkInterface of a VM. Traffic sent to frontendPort of each of the frontendIPConfigurations is forwarded to the backed IP" + }, + "protocol": { + "type": "string", + "description": "Gets or sets the transport potocol for the external endpoint. Possible values are Udp or Tcp", + "enum": [ + "Udp", + "Tcp" + ], + "x-ms-enum": { + "name": "TransportProtocol", + "modelAsString": true + } + }, + "frontendPort": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the port for the external endpoint. You can spcify any port number you choose, but the port numbers specified for each role in the service must be unique. Possible values range between 1 and 65535, inclusive" + }, + "backendPort": { + "type": "integer", + "format": "int32", + "description": "Gets or sets a port used for internal connections on the endpoint. The localPort attribute maps the eternal port of the endpoint to an internal port on a role. This is useful in scenarios where a role must communicate to an internal compotnent on a port that is different from the one that is exposed externally. If not specified, the value of localPort is the same as the port attribute. Set the value of localPort to '*' to automatically assign an unallocated port that is discoverable using the runtime API" + }, + "idleTimeoutInMinutes": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the timeout for the Tcp idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This emlement is only used when the protocol is set to Tcp" + }, + "enableFloatingIP": { + "type": "boolean", + "description": "Configures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn availability Group. This setting is required when using the SQL Always ON availability Groups in SQL server. This setting can't be changed after you create the endpoint" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "frontendPortRangeStart": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the starting port range for the NAT pool. You can spcify any port number you choose, but the port numbers specified for each role in the service must be unique. Possible values range between 1 and 65535, inclusive" - }, - "frontendPortRangeEnd": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the ending port range for the NAT pool. You can spcify any port number you choose, but the port numbers specified for each role in the service must be unique. Possible values range between 1 and 65535, inclusive" - }, - "backendPort": { - "type": "integer", - "format": "int32", - "description": "Gets or sets a port used for internal connections on the endpoint. The localPort attribute maps the eternal port of the endpoint to an internal port on a role. This is useful in scenarios where a role must communicate to an internal compotnent on a port that is different from the one that is exposed externally. If not specified, the value of localPort is the same as the port attribute. Set the value of localPort to '*' to automatically assign an unallocated port that is discoverable using the runtime API" - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "description": "Properties of Inbound NAT rule" }, - "required": [ - "protocol", - "frontendPortRangeStart", - "frontendPortRangeEnd", - "backendPort" - ], - "description": "Properties of Inbound NAT pool" - }, - "InboundNatPool": { - "properties": { - "properties": { - "$ref": "#/definitions/InboundNatPoolPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "InboundNatRule": { + "properties": { + "properties": { + "$ref": "#/components/schemas/InboundNatRulePropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Inbound NAT rule of the loadbalancer" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Inbound NAT pool of the loadbalancer" - }, - "OutboundNatRulePropertiesFormat": { - "properties": { - "allocatedOutboundPorts": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the number of outbound ports to be used for SNAT" - }, - "frontendIPConfigurations": { - "type": "array", - "items": { - "$ref": "#/definitions/SubResource" + "InboundNatPoolPropertiesFormat": { + "properties": { + "frontendIPConfiguration": { + "$ref": "#/components/schemas/SubResource", + "description": "Gets or sets a reference to frontend IP Addresses" }, - "description": "Gets or sets Frontend IP addresses of the load balancer" - }, - "backendAddressPool": { - "$ref": "#/definitions/SubResource", - "description": "Gets or sets a reference to a pool of DIPs. Outbound traffic is randomly load balanced across IPs in the backend IPs" + "protocol": { + "type": "string", + "description": "Gets or sets the transport potocol for the external endpoint. Possible values are Udp or Tcp", + "enum": [ + "Udp", + "Tcp" + ], + "x-ms-enum": { + "name": "TransportProtocol", + "modelAsString": true + } + }, + "frontendPortRangeStart": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the starting port range for the NAT pool. You can spcify any port number you choose, but the port numbers specified for each role in the service must be unique. Possible values range between 1 and 65535, inclusive" + }, + "frontendPortRangeEnd": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the ending port range for the NAT pool. You can spcify any port number you choose, but the port numbers specified for each role in the service must be unique. Possible values range between 1 and 65535, inclusive" + }, + "backendPort": { + "type": "integer", + "format": "int32", + "description": "Gets or sets a port used for internal connections on the endpoint. The localPort attribute maps the eternal port of the endpoint to an internal port on a role. This is useful in scenarios where a role must communicate to an internal compotnent on a port that is different from the one that is exposed externally. If not specified, the value of localPort is the same as the port attribute. Set the value of localPort to '*' to automatically assign an unallocated port that is discoverable using the runtime API" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" + } }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "required": [ + "protocol", + "frontendPortRangeStart", + "frontendPortRangeEnd", + "backendPort" + ], + "description": "Properties of Inbound NAT pool" }, - "required": [ - "backendAddressPool" - ], - "description": "Outbound NAT pool of the loadbalancer" - }, - "OutboundNatRule": { - "properties": { - "properties": { - "$ref": "#/definitions/OutboundNatRulePropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "InboundNatPool": { + "properties": { + "properties": { + "$ref": "#/components/schemas/InboundNatPoolPropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Inbound NAT pool of the loadbalancer" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Outbound NAT pool of the loadbalancer" - }, - "NetworkInterfaceIPConfigurationPropertiesFormat": { - "properties": { - "loadBalancerBackendAddressPools": { - "type": "array", - "items": { - "$ref": "#/definitions/BackendAddressPool" - }, - "description": "Gets or sets the reference of LoadBalancerBackendAddressPool resource" - }, - "loadBalancerInboundNatRules": { - "type": "array", - "items": { - "$ref": "#/definitions/InboundNatRule" + "OutboundNatRulePropertiesFormat": { + "properties": { + "allocatedOutboundPorts": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the number of outbound ports to be used for SNAT" }, - "description": "Gets or sets list of references of LoadBalancerInboundNatRules" - }, - "privateIPAddress": { - "type": "string" - }, - "privateIPAllocationMethod": { - "type": "string", - "description": "Gets or sets PrivateIP allocation method (Static/Dynamic)", - "enum": [ - "Static", - "Dynamic" - ], - "x-ms-enum": { - "name": "IPAllocationMethod", - "modelAsString": true + "frontendIPConfigurations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SubResource" + }, + "description": "Gets or sets Frontend IP addresses of the load balancer" + }, + "backendAddressPool": { + "$ref": "#/components/schemas/SubResource", + "description": "Gets or sets a reference to a pool of DIPs. Outbound traffic is randomly load balanced across IPs in the backend IPs" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "subnet": { - "$ref": "#/definitions/Subnet" - }, - "publicIPAddress": { - "$ref": "#/definitions/PublicIPAddress" - }, - "provisioningState": { - "type": "string" - } + "required": [ + "backendAddressPool" + ], + "description": "Outbound NAT pool of the loadbalancer" }, - "description": "Properties of IPConfiguration" - }, - "NetworkInterfaceIPConfiguration": { - "properties": { + "OutboundNatRule": { "properties": { - "$ref": "#/definitions/NetworkInterfaceIPConfigurationPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "properties": { + "$ref": "#/components/schemas/OutboundNatRulePropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Outbound NAT pool of the loadbalancer" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "IPConfiguration in a NetworkInterface" - }, - "NetworkInterfaceDnsSettings": { - "properties": { - "dnsServers": { - "type": "array", - "items": { - "type": "string" + "NetworkInterfaceIPConfigurationPropertiesFormat": { + "properties": { + "loadBalancerBackendAddressPools": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BackendAddressPool" + }, + "description": "Gets or sets the reference of LoadBalancerBackendAddressPool resource" }, - "description": "Gets or sets list of DNS servers IP addresses" - }, - "appliedDnsServers": { - "type": "array", - "items": { + "loadBalancerInboundNatRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InboundNatRule" + }, + "description": "Gets or sets list of references of LoadBalancerInboundNatRules" + }, + "privateIPAddress": { "type": "string" }, - "description": "Gets or sets list of Applied DNS servers IP addresses" - }, - "internalDnsNameLabel": { - "type": "string", - "description": "Gets or sets the Internal DNS name" + "privateIPAllocationMethod": { + "type": "string", + "description": "Gets or sets PrivateIP allocation method (Static/Dynamic)", + "enum": [ + "Static", + "Dynamic" + ], + "x-ms-enum": { + "name": "IPAllocationMethod", + "modelAsString": true + } + }, + "subnet": { + "$ref": "#/components/schemas/Subnet" + }, + "publicIPAddress": { + "$ref": "#/components/schemas/PublicIPAddress" + }, + "provisioningState": { + "type": "string" + } }, - "internalFqdn": { - "type": "string", - "description": "Gets or sets full IDNS name in the form, DnsName.VnetId.ZoneId.TopleveSuffix. This is set when the NIC is associated to a VM" - } + "description": "Properties of IPConfiguration" }, - "description": "Dns Settings of a network interface" - }, - "NetworkInterfacePropertiesFormat": { - "properties": { - "virtualMachine": { - "$ref": "#/definitions/SubResource", - "description": "Gets or sets the reference of a VirtualMachine" - }, - "networkSecurityGroup": { - "$ref": "#/definitions/NetworkSecurityGroup", - "description": "Gets or sets the reference of the NetworkSecurityGroup resource" - }, - "ipConfigurations": { - "type": "array", - "items": { - "$ref": "#/definitions/NetworkInterfaceIPConfiguration" + "NetworkInterfaceIPConfiguration": { + "properties": { + "properties": { + "$ref": "#/components/schemas/NetworkInterfaceIPConfigurationPropertiesFormat" }, - "description": "Gets or sets list of IPConfigurations of the NetworkInterface" - }, - "dnsSettings": { - "$ref": "#/definitions/NetworkInterfaceDnsSettings", - "description": "Gets or sets DNS Settings in NetworkInterface" - }, - "macAddress": { - "type": "string", - "description": "Gets the MAC Address of the network interface" - }, - "primary": { - "type": "boolean", - "description": "Gets whether this is a primary NIC on a virtual machine" - }, - "enableIPForwarding": { - "type": "boolean", - "description": "Gets or sets whether IPForwarding is enabled on the NIC" - }, - "resourceGuid": { - "type": "string", - "description": "Gets or sets resource guid property of the network interface resource" + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "IPConfiguration in a NetworkInterface" }, - "description": "NetworkInterface properties. " - }, - "NetworkInterface": { - "properties": { + "NetworkInterfaceDnsSettings": { "properties": { - "$ref": "#/definitions/NetworkInterfacePropertiesFormat" + "dnsServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Gets or sets list of DNS servers IP addresses" + }, + "appliedDnsServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Gets or sets list of Applied DNS servers IP addresses" + }, + "internalDnsNameLabel": { + "type": "string", + "description": "Gets or sets the Internal DNS name" + }, + "internalFqdn": { + "type": "string", + "description": "Gets or sets full IDNS name in the form, DnsName.VnetId.ZoneId.TopleveSuffix. This is set when the NIC is associated to a VM" + } }, - "etag": { - "type": "string", - "description": "Gets a unique read-only string that changes whenever the resource is updated" - } + "description": "Dns Settings of a network interface" }, - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "A NetworkInterface in a resource group" - }, - "SecurityRulePropertiesFormat": { - "properties": { - "description": { - "type": "string", - "description": "Gets or sets a description for this rule. Restricted to 140 chars." - }, - "protocol": { - "type": "string", - "description": "Gets or sets Network protocol this rule applies to. Can be Tcp, Udp or All(*).", - "enum": [ - "Tcp", - "Udp", - "*" - ], - "x-ms-enum": { - "name": "SecurityRuleProtocol", - "modelAsString": true + "NetworkInterfacePropertiesFormat": { + "properties": { + "virtualMachine": { + "$ref": "#/components/schemas/SubResource", + "description": "Gets or sets the reference of a VirtualMachine" + }, + "networkSecurityGroup": { + "$ref": "#/components/schemas/NetworkSecurityGroup", + "description": "Gets or sets the reference of the NetworkSecurityGroup resource" + }, + "ipConfigurations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NetworkInterfaceIPConfiguration" + }, + "description": "Gets or sets list of IPConfigurations of the NetworkInterface" + }, + "dnsSettings": { + "$ref": "#/components/schemas/NetworkInterfaceDnsSettings", + "description": "Gets or sets DNS Settings in NetworkInterface" + }, + "macAddress": { + "type": "string", + "description": "Gets the MAC Address of the network interface" + }, + "primary": { + "type": "boolean", + "description": "Gets whether this is a primary NIC on a virtual machine" + }, + "enableIPForwarding": { + "type": "boolean", + "description": "Gets or sets whether IPForwarding is enabled on the NIC" + }, + "resourceGuid": { + "type": "string", + "description": "Gets or sets resource guid property of the network interface resource" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "sourcePortRange": { - "type": "string", - "description": "Gets or sets Source Port or Range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports." - }, - "destinationPortRange": { - "type": "string", - "description": "Gets or sets Destination Port or Range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports." - }, - "sourceAddressPrefix": { - "type": "string", - "description": "Gets or sets source address prefix. CIDR or source IP range. Asterix '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. If this is an ingress rule, specifies where network traffic originates from. " - }, - "destinationAddressPrefix": { - "type": "string", - "description": "Gets or sets destination address prefix. CIDR or source IP range. Asterix '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. " - }, - "access": { - "type": "string", - "description": "Gets or sets network traffic is allowed or denied. Possible values are 'Allow' and 'Deny'", - "enum": [ - "Allow", - "Deny" - ], - "x-ms-enum": { - "name": "SecurityRuleAccess", - "modelAsString": true + "description": "NetworkInterface properties. " + }, + "NetworkInterface": { + "properties": { + "properties": { + "$ref": "#/components/schemas/NetworkInterfacePropertiesFormat" + }, + "etag": { + "type": "string", + "description": "Gets a unique read-only string that changes whenever the resource is updated" } }, - "priority": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule." - }, - "direction": { - "type": "string", - "description": "Gets or sets the direction of the rule.InBound or Outbound. The direction specifies if rule will be evaluated on incoming or outcoming traffic.", - "enum": [ - "Inbound", - "Outbound" - ], - "x-ms-enum": { - "name": "SecurityRuleDirection", - "modelAsString": true + "allOf": [ + { + "$ref": "#/components/schemas/Resource" } - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + ], + "description": "A NetworkInterface in a resource group" }, - "required": [ - "protocol", - "sourceAddressPrefix", - "destinationAddressPrefix", - "access", - "direction" - ] - }, - "SecurityRule": { - "properties": { - "properties": { - "$ref": "#/definitions/SecurityRulePropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "SecurityRulePropertiesFormat": { + "properties": { + "description": { + "type": "string", + "description": "Gets or sets a description for this rule. Restricted to 140 chars." + }, + "protocol": { + "type": "string", + "description": "Gets or sets Network protocol this rule applies to. Can be Tcp, Udp or All(*).", + "enum": [ + "Tcp", + "Udp", + "*" + ], + "x-ms-enum": { + "name": "SecurityRuleProtocol", + "modelAsString": true + } + }, + "sourcePortRange": { + "type": "string", + "description": "Gets or sets Source Port or Range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports." + }, + "destinationPortRange": { + "type": "string", + "description": "Gets or sets Destination Port or Range. Integer or range between 0 and 65535. Asterix '*' can also be used to match all ports." + }, + "sourceAddressPrefix": { + "type": "string", + "description": "Gets or sets source address prefix. CIDR or source IP range. Asterix '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. If this is an ingress rule, specifies where network traffic originates from. " + }, + "destinationAddressPrefix": { + "type": "string", + "description": "Gets or sets destination address prefix. CIDR or source IP range. Asterix '*' can also be used to match all source IPs. Default tags such as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used. " + }, + "access": { + "type": "string", + "description": "Gets or sets network traffic is allowed or denied. Possible values are 'Allow' and 'Deny'", + "enum": [ + "Allow", + "Deny" + ], + "x-ms-enum": { + "name": "SecurityRuleAccess", + "modelAsString": true + } + }, + "priority": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the priority of the rule. The value can be between 100 and 4096. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule." + }, + "direction": { + "type": "string", + "description": "Gets or sets the direction of the rule.InBound or Outbound. The direction specifies if rule will be evaluated on incoming or outcoming traffic.", + "enum": [ + "Inbound", + "Outbound" + ], + "x-ms-enum": { + "name": "SecurityRuleDirection", + "modelAsString": true + } + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "required": [ + "protocol", + "sourceAddressPrefix", + "destinationAddressPrefix", + "access", + "direction" + ] }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Network security rule" - }, - "NetworkSecurityGroupPropertiesFormat": { - "properties": { - "securityRules": { - "type": "array", - "items": { - "$ref": "#/definitions/SecurityRule" - }, - "description": "Gets or sets Security rules of network security group" - }, - "defaultSecurityRules": { - "type": "array", - "items": { - "$ref": "#/definitions/SecurityRule" + "SecurityRule": { + "properties": { + "properties": { + "$ref": "#/components/schemas/SecurityRulePropertiesFormat" }, - "description": "Gets or sets Default security rules of network security group" - }, - "networkInterfaces": { - "type": "array", - "items": { - "$ref": "#/definitions/NetworkInterface" + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" }, - "description": "Gets collection of references to Network Interfaces" + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "subnets": { - "type": "array", - "items": { - "$ref": "#/definitions/Subnet" + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Network security rule" + }, + "NetworkSecurityGroupPropertiesFormat": { + "properties": { + "securityRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SecurityRule" + }, + "description": "Gets or sets Security rules of network security group" }, - "description": "Gets collection of references to subnets" - }, - "resourceGuid": { - "type": "string", - "description": "Gets or sets resource guid property of the network security group resource" + "defaultSecurityRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SecurityRule" + }, + "description": "Gets or sets Default security rules of network security group" + }, + "networkInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NetworkInterface" + }, + "description": "Gets collection of references to Network Interfaces" + }, + "subnets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Subnet" + }, + "description": "Gets collection of references to subnets" + }, + "resourceGuid": { + "type": "string", + "description": "Gets or sets resource guid property of the network security group resource" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" + } }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "description": "Network Security Group resource" }, - "description": "Network Security Group resource" - }, - "NetworkSecurityGroup": { - "properties": { + "NetworkSecurityGroup": { "properties": { - "$ref": "#/definitions/NetworkSecurityGroupPropertiesFormat" + "properties": { + "$ref": "#/components/schemas/NetworkSecurityGroupPropertiesFormat" + }, + "etag": { + "type": "string", + "description": "Gets a unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "Gets a unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/Resource" + } + ], + "description": "NetworkSecurityGroup resource" }, - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "NetworkSecurityGroup resource" - }, - "PublicIPAddressDnsSettings": { - "properties": { - "domainNameLabel": { - "type": "string", - "description": "Gets or sets the Domain name label.The concatenation of the domain name label and the regionalized DNS zone make up the fully qualified domain name associated with the public IP address. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system." - }, - "fqdn": { - "type": "string", - "description": "Gets the FQDN, Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone." + "PublicIPAddressDnsSettings": { + "properties": { + "domainNameLabel": { + "type": "string", + "description": "Gets or sets the Domain name label.The concatenation of the domain name label and the regionalized DNS zone make up the fully qualified domain name associated with the public IP address. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system." + }, + "fqdn": { + "type": "string", + "description": "Gets the FQDN, Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone." + }, + "reverseFqdn": { + "type": "string", + "description": "Gets or Sests the Reverse FQDN. A user-visible, fully qualified domain name that resolves to this public IP address. If the reverseFqdn is specified, then a PTR DNS record is created pointing from the IP address in the in-addr.arpa domain to the reverse FQDN. " + } }, - "reverseFqdn": { - "type": "string", - "description": "Gets or Sests the Reverse FQDN. A user-visible, fully qualified domain name that resolves to this public IP address. If the reverseFqdn is specified, then a PTR DNS record is created pointing from the IP address in the in-addr.arpa domain to the reverse FQDN. " - } + "description": "Contains FQDN of the DNS record associated with the public IP address" }, - "description": "Contains FQDN of the DNS record associated with the public IP address" - }, - "PublicIPAddressPropertiesFormat": { - "properties": { - "publicIPAllocationMethod": { - "type": "string", - "description": "Gets or sets PublicIP allocation method (Static/Dynamic)", - "enum": [ - "Static", - "Dynamic" - ], - "x-ms-enum": { - "name": "IPAllocationMethod", - "modelAsString": true + "PublicIPAddressPropertiesFormat": { + "properties": { + "publicIPAllocationMethod": { + "type": "string", + "description": "Gets or sets PublicIP allocation method (Static/Dynamic)", + "enum": [ + "Static", + "Dynamic" + ], + "x-ms-enum": { + "name": "IPAllocationMethod", + "modelAsString": true + } + }, + "ipConfiguration": { + "$ref": "#/components/schemas/IPConfiguration" + }, + "dnsSettings": { + "$ref": "#/components/schemas/PublicIPAddressDnsSettings", + "description": "Gets or sets FQDN of the DNS record associated with the public IP address" + }, + "ipAddress": { + "type": "string" + }, + "idleTimeoutInMinutes": { + "type": "integer", + "format": "int32", + "description": "Gets or sets the Idletimeout of the public IP address" + }, + "resourceGuid": { + "type": "string", + "description": "Gets or sets resource guid property of the PublicIP resource" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "ipConfiguration": { - "$ref": "#/definitions/IPConfiguration" - }, - "dnsSettings": { - "$ref": "#/definitions/PublicIPAddressDnsSettings", - "description": "Gets or sets FQDN of the DNS record associated with the public IP address" - }, - "ipAddress": { - "type": "string" - }, - "idleTimeoutInMinutes": { - "type": "integer", - "format": "int32", - "description": "Gets or sets the Idletimeout of the public IP address" - }, - "resourceGuid": { - "type": "string", - "description": "Gets or sets resource guid property of the PublicIP resource" - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "description": "PublicIpAddress properties" }, - "description": "PublicIpAddress properties" - }, - "PublicIPAddress": { - "properties": { + "PublicIPAddress": { "properties": { - "$ref": "#/definitions/PublicIPAddressPropertiesFormat" + "properties": { + "$ref": "#/components/schemas/PublicIPAddressPropertiesFormat" + }, + "etag": { + "type": "string", + "description": "Gets a unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "Gets a unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/Resource" + } + ], + "description": "PublicIPAddress resource" }, - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "PublicIPAddress resource" - }, - "RoutePropertiesFormat": { - "properties": { - "addressPrefix": { - "type": "string", - "description": "Gets or sets the destination CIDR to which the route applies." - }, - "nextHopType": { - "type": "string", - "description": "Gets or sets the type of Azure hop the packet should be sent to.", - "enum": [ - "VirtualNetworkGateway", - "VnetLocal", - "Internet", - "VirtualAppliance", - "None" - ], - "x-ms-enum": { - "name": "RouteNextHopType", - "modelAsString": true + "RoutePropertiesFormat": { + "properties": { + "addressPrefix": { + "type": "string", + "description": "Gets or sets the destination CIDR to which the route applies." + }, + "nextHopType": { + "type": "string", + "description": "Gets or sets the type of Azure hop the packet should be sent to.", + "enum": [ + "VirtualNetworkGateway", + "VnetLocal", + "Internet", + "VirtualAppliance", + "None" + ], + "x-ms-enum": { + "name": "RouteNextHopType", + "modelAsString": true + } + }, + "nextHopIpAddress": { + "type": "string", + "description": "Gets or sets the IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance." + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the resource Updating/Deleting/Failed" } }, - "nextHopIpAddress": { - "type": "string", - "description": "Gets or sets the IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance." - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the resource Updating/Deleting/Failed" - } + "required": [ + "nextHopType" + ], + "description": "Route resource" }, - "required": [ - "nextHopType" - ], - "description": "Route resource" - }, - "Route": { - "properties": { - "properties": { - "$ref": "#/definitions/RoutePropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "Route": { + "properties": { + "properties": { + "$ref": "#/components/schemas/RoutePropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Route resource" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Route resource" - }, - "RouteTablePropertiesFormat": { - "properties": { - "routes": { - "type": "array", - "items": { - "$ref": "#/definitions/Route" - }, - "description": "Gets or sets Routes in a Route Table" - }, - "subnets": { - "type": "array", - "items": { - "$ref": "#/definitions/Subnet" + "RouteTablePropertiesFormat": { + "properties": { + "routes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Route" + }, + "description": "Gets or sets Routes in a Route Table" }, - "description": "Gets collection of references to subnets" + "subnets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Subnet" + }, + "description": "Gets collection of references to subnets" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the resource Updating/Deleting/Failed" + } }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the resource Updating/Deleting/Failed" - } + "description": "Route Table resource" }, - "description": "Route Table resource" - }, - "RouteTable": { - "properties": { + "RouteTable": { "properties": { - "$ref": "#/definitions/RouteTablePropertiesFormat" + "properties": { + "$ref": "#/components/schemas/RouteTablePropertiesFormat" + }, + "etag": { + "type": "string", + "description": "Gets a unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "Gets a unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/Resource" + } + ], + "description": "RouteTable resource" }, - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "RouteTable resource" - }, - "IPConfigurationPropertiesFormat": { - "properties": { - "privateIPAddress": { - "type": "string", - "description": "Gets or sets the privateIPAddress of the IP Configuration" - }, - "privateIPAllocationMethod": { - "type": "string", - "description": "Gets or sets PrivateIP allocation method (Static/Dynamic)", - "enum": [ - "Static", - "Dynamic" - ], - "x-ms-enum": { - "name": "IPAllocationMethod", - "modelAsString": true + "IPConfigurationPropertiesFormat": { + "properties": { + "privateIPAddress": { + "type": "string", + "description": "Gets or sets the privateIPAddress of the IP Configuration" + }, + "privateIPAllocationMethod": { + "type": "string", + "description": "Gets or sets PrivateIP allocation method (Static/Dynamic)", + "enum": [ + "Static", + "Dynamic" + ], + "x-ms-enum": { + "name": "IPAllocationMethod", + "modelAsString": true + } + }, + "subnet": { + "$ref": "#/components/schemas/Subnet", + "description": "Gets or sets the reference of the subnet resource" + }, + "publicIPAddress": { + "$ref": "#/components/schemas/PublicIPAddress", + "description": "Gets or sets the reference of the PublicIP resource" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" } }, - "subnet": { - "$ref": "#/definitions/Subnet", - "description": "Gets or sets the reference of the subnet resource" - }, - "publicIPAddress": { - "$ref": "#/definitions/PublicIPAddress", - "description": "Gets or sets the reference of the PublicIP resource" - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" - } + "description": "Properties of IPConfiguration" }, - "description": "Properties of IPConfiguration" - }, - "IPConfiguration": { - "properties": { + "IPConfiguration": { "properties": { - "$ref": "#/definitions/IPConfigurationPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "properties": { + "$ref": "#/components/schemas/IPConfigurationPropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "IPConfiguration" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "IPConfiguration" - }, - "SubnetPropertiesFormat": { - "properties": { - "addressPrefix": { - "type": "string", - "description": "Gets or sets Address prefix for the subnet." - }, - "networkSecurityGroup": { - "$ref": "#/definitions/NetworkSecurityGroup", - "description": "Gets or sets the reference of the NetworkSecurityGroup resource" - }, - "routeTable": { - "$ref": "#/definitions/RouteTable", - "description": "Gets or sets the reference of the RouteTable resource" - }, - "ipConfigurations": { - "type": "array", - "items": { - "$ref": "#/definitions/IPConfiguration" + "SubnetPropertiesFormat": { + "properties": { + "addressPrefix": { + "type": "string", + "description": "Gets or sets Address prefix for the subnet." }, - "description": "Gets array of references to the network interface IP configurations using subnet" - }, - "provisioningState": { - "type": "string", - "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" + "networkSecurityGroup": { + "$ref": "#/components/schemas/NetworkSecurityGroup", + "description": "Gets or sets the reference of the NetworkSecurityGroup resource" + }, + "routeTable": { + "$ref": "#/components/schemas/RouteTable", + "description": "Gets or sets the reference of the RouteTable resource" + }, + "ipConfigurations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IPConfiguration" + }, + "description": "Gets array of references to the network interface IP configurations using subnet" + }, + "provisioningState": { + "type": "string", + "description": "Gets or sets Provisioning state of the PublicIP resource Updating/Deleting/Failed" + } } - } - }, - "Subnet": { - "properties": { + }, + "Subnet": { "properties": { - "$ref": "#/definitions/SubnetPropertiesFormat" - }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + "properties": { + "$ref": "#/components/schemas/SubnetPropertiesFormat" + }, + "name": { + "type": "string", + "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" + }, + "etag": { + "type": "string", + "description": "A unique read-only string that changes whenever the resource is updated" + } }, - "etag": { - "type": "string", - "description": "A unique read-only string that changes whenever the resource is updated" - } + "allOf": [ + { + "$ref": "#/components/schemas/SubResource" + } + ], + "description": "Subnet in a VirtualNework resource" }, - "allOf": [ - { - "$ref": "#/definitions/SubResource" - } - ], - "description": "Subnet in a VirtualNework resource" - }, - "Resource": { - "properties": { - "id": { - "type": "string", - "description": "Resource Id" - }, - "name": { - "readOnly": true, - "type": "string", - "description": "Resource name" - }, - "type": { - "readOnly": true, - "type": "string", - "description": "Resource type" - }, - "location": { - "type": "string", - "description": "Resource location" - }, - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" + "Resource": { + "properties": { + "id": { + "type": "string", + "description": "Resource Id" }, - "description": "Resource tags" - } - }, - "x-ms-azure-resource": true - }, - "SubResource": { - "properties": { - "id": { - "type": "string", - "description": "Resource Id" - } + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "x-ms-azure-resource": true }, - "x-ms-azure-resource": true + "SubResource": { + "properties": { + "id": { + "type": "string", + "description": "Resource Id" + } + }, + "x-ms-azure-resource": true + } } } } \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-data-types.json b/test/Resource/Swagger/swagger-data-types.json index 63564cf..55a6391 100644 --- a/test/Resource/Swagger/swagger-data-types.json +++ b/test/Resource/Swagger/swagger-data-types.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Microsoft Azure Redis Cache Management API", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{integer}/{int}/{long}/{number}/{float}/{double}/{string}/{enum}/{byte}/{boolean}/{date}/{dateTime}/{base64url}?invalues='{array}'": { "get": { @@ -22,97 +20,152 @@ { "name": "integer", "in": "path", - "type": "integer" + "schema": { + "type": "integer" + }, + "required": true }, { "name": "int", "in": "path", - "type": "integer", - "format": "int32" + "schema": { + "type": "integer", + "format": "int32" + }, + "required": true }, { "name": "long", "in": "path", - "type": "integer", - "format": "int64" + "schema": { + "type": "integer", + "format": "int64" + }, + "required": true }, { "name": "number", "in": "path", - "type": "number" + "schema": { + "type": "number" + }, + "required": true }, { "name": "float", "in": "path", - "type": "number", - "format": "float" + "schema": { + "type": "number", + "format": "float" + }, + "required": true }, { "name": "double", "in": "path", - "type": "number", - "format": "double" + "schema": { + "type": "number", + "format": "double" + }, + "required": true }, { "name": "decimal", "in": "path", - "type": "number", - "format": "decimal" + "schema": { + "type": "number", + "format": "decimal" + }, + "required": true }, { "name": "string", "in": "path", - "type": "string" + "schema": { + "type": "string" + }, + "required": true }, { "name": "color", "in": "path", - "type": "string", - "enum": [ "red", "blue", "green" ] + "schema": { + "type": "string", + "enum": [ + "red", + "blue", + "green" + ] + }, + "required": true }, { "name": "byte", "in": "path", - "type": "string", - "format": "byte" + "schema": { + "type": "string", + "format": "byte" + }, + "required": true }, { "name": "boolean", "in": "path", - "type": "boolean" + "schema": { + "type": "boolean" + }, + "required": true }, { "name": "date", "in": "path", - "type": "string", - "format": "date" + "schema": { + "type": "string", + "format": "date" + }, + "required": true }, { "name": "dateTime", "in": "path", - "type": "string", - "format": "date-time" + "schema": { + "type": "string", + "format": "date-time" + }, + "required": true }, { "name": "base64url", "in": "path", - "type": "string", - "format": "base64url" + "schema": { + "type": "string", + "format": "base64url" + }, + "required": true }, { "name": "array", "in": "query", - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } }, { "name": "color", "in": "query", - "type": "string", - "enum": [ "red", "blue", "green", "purple" ] + "schema": { + "type": "string", + "enum": [ + "red", + "blue", + "green", + "purple" + ] + } } ], "tags": [ @@ -121,14 +174,22 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -142,24 +203,37 @@ { "name": "color", "in": "query", - "type": "string", - "enum": [ "cyan", "yellow" ] + "schema": { + "type": "string", + "enum": [ + "cyan", + "yellow" + ] + } } ], "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "string", - "additionalProperties": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "type": "string", + "additionalProperties": { + "$ref": "#/components/schemas/Product" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -173,24 +247,38 @@ { "name": "color2", "in": "query", - "type": "string", - "enum": [ "blue", "green", "red" ] + "schema": { + "type": "string", + "enum": [ + "blue", + "green", + "red" + ] + } } ], "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "string", - "additionalProperties": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "type": "string", + "additionalProperties": { + "$ref": "#/components/schemas/Product" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -203,17 +291,25 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "string", - "additionalProperties": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "type": "string", + "additionalProperties": { + "$ref": "#/components/schemas/Product" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -226,17 +322,25 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "string", - "additionalProperties": { - "type": "string" + "content": { + "application/json": { + "schema": { + "type": "string", + "additionalProperties": { + "type": "string" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -247,17 +351,25 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "string", - "additionalProperties": { - "type": "integer" + "content": { + "application/json": { + "schema": { + "type": "string", + "additionalProperties": { + "type": "integer" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -270,17 +382,25 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -288,229 +408,268 @@ "put": { "operationId": "put", "summary": "Create Product Types", - "parameters": [ - { - "name": "product", - "in": "body", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" - } - } - } - ], "responses": { "200": { "description": "A list of caches", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/ProductArray" + }, + "x-ms-requestBody-index": 0 }, "post": { "operationId": "post", "summary": "Post product", - "parameters": [ - { - "name": "product", - "in": "body", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" - } - } - } - ], "responses": { "200": { "description": "OK", - "schema": { - "$ref": "#/definitions/Object" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Object" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/ProductArray" + }, + "x-ms-requestBody-index": 0 } } }, - "definitions": { - "Product": { - "type": "object", - "properties": { - "integer": { - "type": "integer" - }, - "int": { - "type": "integer", - "format": "int32" - }, - "long": { - "type": "integer", - "format": "int64" - }, - "number": { - "type": "number" - }, - "float": { - "type": "number", - "format": "float" - }, - "double": { - "type": "number", - "format": "double" - }, - "string": { - "type": "string" - }, - "color": { - "x-ms-enum": { "name": "Colors", "modelAsString": false }, - "type": "string", - "enum": [ "red", "blue", "green" ] - }, - "color2": { - "type": "string", - "enum": [ "red", "blue", "green" ] - }, - "color3": { - "x-ms-enum": { "name": "Colors", "modelAsString": false }, - "type": "string", - "enum": [ "red", "green", "blue" ] - }, - "refColor": { - "$ref": "#/definitions/RefColor" - }, - "byte": { - "type": "string", - "format": "byte" - }, - "boolean": { - "type": "boolean" - }, - "date": { - "type": "string", - "format": "date" - }, - "dateTime": { - "type": "string", - "format": "date-time" - }, - "integerArray": { - "type": "array", - "items": { + "components": { + "schemas": { + "Product": { + "type": "object", + "properties": { + "integer": { "type": "integer" - } - }, - "intArray": { - "type": "array", - "items": { + }, + "int": { "type": "integer", "format": "int32" - } - }, - "longArray": { - "type": "array", - "items": { + }, + "long": { "type": "integer", "format": "int64" - } - }, - "numberArray": { - "type": "array", - "items": { + }, + "number": { "type": "number" - } - }, - "floatArray": { - "type": "array", - "items": { + }, + "float": { "type": "number", "format": "float" - } - }, - "doubleArray": { - "type": "array", - "items": { + }, + "double": { "type": "number", "format": "double" - } - }, - "booleanArray": { - "type": "array", - "items": { - "type": "boolean" - } - }, - "stringArray": { - "type": "array", - "items": { + }, + "string": { "type": "string" - } - }, - "byteArrayArray": { - "type": "array", - "items": { + }, + "color": { + "x-ms-enum": { + "name": "Colors", + "modelAsString": false + }, + "type": "string", + "enum": [ + "red", + "blue", + "green" + ] + }, + "color2": { + "type": "string", + "enum": [ + "red", + "blue", + "green" + ] + }, + "color3": { + "x-ms-enum": { + "name": "Colors", + "modelAsString": false + }, + "type": "string", + "enum": [ + "red", + "green", + "blue" + ] + }, + "refColor": { + "$ref": "#/components/schemas/RefColor" + }, + "byte": { "type": "string", "format": "byte" - } - }, - "dateArray": { - "type": "array", - "items": { + }, + "boolean": { + "type": "boolean" + }, + "date": { "type": "string", "format": "date" - } - }, - "dateTimeArray": { - "type": "array", - "items": { + }, + "dateTime": { "type": "string", "format": "date-time" + }, + "integerArray": { + "type": "array", + "items": { + "type": "integer" + } + }, + "intArray": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + }, + "longArray": { + "type": "array", + "items": { + "type": "integer", + "format": "int64" + } + }, + "numberArray": { + "type": "array", + "items": { + "type": "number" + } + }, + "floatArray": { + "type": "array", + "items": { + "type": "number", + "format": "float" + } + }, + "doubleArray": { + "type": "array", + "items": { + "type": "number", + "format": "double" + } + }, + "booleanArray": { + "type": "array", + "items": { + "type": "boolean" + } + }, + "stringArray": { + "type": "array", + "items": { + "type": "string" + } + }, + "byteArrayArray": { + "type": "array", + "items": { + "type": "string", + "format": "byte" + } + }, + "dateArray": { + "type": "array", + "items": { + "type": "string", + "format": "date" + } + }, + "dateTimeArray": { + "type": "array", + "items": { + "type": "string", + "format": "date-time" + } } } - } - }, - "Object": { - "type": "object", - "properties": { } - }, - "RefColor": { - "x-ms-enum": { - "name": "refColors", - "modelAsString": true }, - "type": "string", - "enum": [ "red", "green", "blue" ] - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" + "Object": { + "type": "object", + "properties": {} + }, + "RefColor": { + "x-ms-enum": { + "name": "refColors", + "modelAsString": true }, - "fields": { - "type": "string" + "type": "string", + "enum": [ + "red", + "green", + "blue" + ] + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } + } + } + }, + "requestBodies": { + "ProductArray": { + "x-ms-client-name": "product", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } + } + } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-external-def.json b/test/Resource/Swagger/swagger-external-def.json index 8a3e9fe..929d263 100644 --- a/test/Resource/Swagger/swagger-external-def.json +++ b/test/Resource/Swagger/swagger-external-def.json @@ -1,96 +1,109 @@ { - "definitions": { - "Product": { - "x-ms-external" : null, - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people." - }, - "image": { - "type": "string", - "description": "Image URL representing the product." + "openapi": "3.0.0", + "servers": [], + "info": { + "version": "", + "title": "" + }, + "paths": {}, + "components": { + "schemas": { + "Product": { + "x-ms-external": null, + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people." + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } } - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } } - } - }, - "Pet": { - "required": [ "type" ], - "discriminator": "type", - "properties": { - "id": { - "type": "integer", - "format": "int32" - }, - "type": { - "type": "string" + }, + "Pet": { + "required": [ + "type" + ], + "discriminator": { + "propertyName": "type" }, - "name": { - "type": "string" - } - } - }, - "Cat": { - "properties": { - "color": { - "type": "string" + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + }, + "name": { + "type": "string" + } } }, - "allOf": [ - { - "$ref": "#/definitions/Pet" - } - ] - }, - "Dog": { - "properties": { - "weight": { - "type": "integer", - "format": "int32" - } + "Cat": { + "properties": { + "color": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + } + ] }, - "allOf": [ - { - "$ref": "#/definitions/Pet" - } - ] - }, - "SiameseCat": { - "properties": { - "eyeColor": { - "type": "string" - } + "Dog": { + "properties": { + "weight": { + "type": "integer", + "format": "int32" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + } + ] }, - "allOf": [ - { - "$ref": "#/definitions/Cat" - } - ] + "SiameseCat": { + "properties": { + "eyeColor": { + "type": "string" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/Cat" + } + ] + } } } } \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-external-ref-no-definitions.json b/test/Resource/Swagger/swagger-external-ref-no-definitions.json index 0d34c02..fa767c2 100644 --- a/test/Resource/Swagger/swagger-external-ref-no-definitions.json +++ b/test/Resource/Swagger/swagger-external-ref-no-definitions.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Microsoft Azure Redis Cache Management API", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { "get": { @@ -24,21 +22,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -47,14 +51,22 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Product" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Product" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Error" + } + } } } } @@ -69,21 +81,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -95,12 +113,16 @@ }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Error" + } + } } } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-external-ref.json b/test/Resource/Swagger/swagger-external-ref.json index 4eee722..caf1f53 100644 --- a/test/Resource/Swagger/swagger-external-ref.json +++ b/test/Resource/Swagger/swagger-external-ref.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Microsoft Azure Redis Cache Management API", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { "get": { @@ -24,21 +22,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -47,20 +51,32 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Product" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Product" + } + } } }, "201": { "description": "A list of child caches", - "schema": { - "$ref": "#/definitions/ChildProduct" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChildProduct" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Error" + } + } } } } @@ -75,21 +91,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -101,8 +123,12 @@ }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Error" + } + } } } } @@ -119,21 +145,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group name.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "petName", "in": "path", "description": "Pet name.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -142,26 +174,36 @@ "responses": { "200": { "description": "A list of pets.", - "schema": { - "$ref": "./swagger-external-def.json#/definitions/Pet" + "content": { + "application/json": { + "schema": { + "$ref": "./swagger-external-def.json#/definitions/Pet" + } + } } } } } } }, - "definitions": { - "ChildProduct": { - "allOf": [ { "$ref": "./swagger-external-def.json#/definitions/Product" } ], - "properties": { - "size": { - "type": "integer", - "description": "product size" - }, - "parentProduct": { - "$ref": "./swagger-external-def.json#/definitions/Product" + "components": { + "schemas": { + "ChildProduct": { + "allOf": [ + { + "$ref": "./swagger-external-def.json#/definitions/Product" + } + ], + "properties": { + "size": { + "type": "integer", + "description": "product size" + }, + "parentProduct": { + "$ref": "./swagger-external-def.json#/definitions/Product" + } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-global-responses.json b/test/Resource/Swagger/swagger-global-responses.json index 9305dab..e66a57d 100644 --- a/test/Resource/Swagger/swagger-global-responses.json +++ b/test/Resource/Swagger/swagger-global-responses.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Global Responses", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { "get": { @@ -24,21 +22,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -46,74 +50,88 @@ ], "responses": { "200": { - "$ref": "#/responses/successGetUserResponse" + "$ref": "#/components/responses/successGetUserResponse" }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } } } }, - "definitions": { - "Product": { - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people." - }, - "image": { - "type": "string", - "description": "Image URL representing the product." + "components": { + "schemas": { + "Product": { + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people." + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } } - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } } } - } - }, - "responses": { - "successGetUserResponse": { - "description": "Product found", - "schema": { - "$ref": "#/definitions/Product" - }, - "headers": { - "ocp-aad-diagnositcs-server-name": { - "type": "string", - "description": "The identifier for the server that performed the requested operation." + }, + "responses": { + "successGetUserResponse": { + "description": "Product found", + "headers": { + "ocp-aad-diagnositcs-server-name": { + "description": "The identifier for the server that performed the requested operation.", + "schema": { + "type": "string" + } + }, + "ocp-aad-session-key": { + "description": "The key that identifies the current session with the directory service.", + "schema": { + "type": "string" + } + } }, - "ocp-aad-session-key": { - "description": "The key that identifies the current session with the directory service.", - "type": "string" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-multiple-response-schemas.json b/test/Resource/Swagger/swagger-multiple-response-schemas.json index 8acbcfd..6a33076 100644 --- a/test/Resource/Swagger/swagger-multiple-response-schemas.json +++ b/test/Resource/Swagger/swagger-multiple-response-schemas.json @@ -1,5 +1,13 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "http://petstore.swagger.wordnik.com/api" + }, + { + "url": "https://petstore.swagger.wordnik.com/api" + } + ], "info": { "version": "1.0.0", "title": "Swagger Petstore", @@ -15,88 +23,281 @@ "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" } }, - "host": "petstore.swagger.wordnik.com", - "basePath": "/api", - "schemes": [ - "http", - "https" - ], - "consumes": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/octet-stream", - "application/zip", - "application/gzip" - ], - "produces": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/atom+xml; charset=utf-8", - "application/octet-stream", - "application/zip", - "application/gzip" - ], "paths": { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "getSameResponse", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, - "type": "integer", - "format": "int32" + "schema": { + "type": "integer", + "format": "int32" + } } ], "responses": { "200": { "description": "200 response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/html": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/json; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/octet-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/zip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/gzip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } } } }, "202": { "description": "202 response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/html": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/json; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/octet-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/zip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/gzip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } } @@ -104,259 +305,798 @@ "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "postInheretedTypes", - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/newPet" - } - } - ], "responses": { "200": { "description": "pet response", - "schema": { - "$ref": "#/definitions/dog" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/dog" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/dog" + } + } } }, "201": { "description": "cat response", - "schema": { - "$ref": "#/definitions/cat" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/cat" + } + } } }, "202": { "description": "cat response", - "schema": { - "$ref": "#/definitions/cat" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/cat" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/cat" + } + } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "pet", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } + }, + "description": "Pet to add to the store", + "required": true + }, + "x-ms-requestBody-index": 0 }, "put": { - "tags": [ ], + "tags": [], "summary": "", "description": "", "operationId": "putSameResponseType", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], "responses": { "200": { - "$ref": "#/responses/petResponse" + "$ref": "#/components/responses/petResponse" }, "203": { - "$ref": "#/responses/petResponse" + "$ref": "#/components/responses/petResponse" }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } }, - "schemes": [ - "http", - "https" - ], "x-test-header-info": { "name": "x-static-header", "value": "headerValue" - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/pet" + }, + "x-ms-requestBody-index": 0 }, "delete": { - "tags": [ ], + "tags": [], "summary": "", "description": "", "operationId": "deleteDifferentTypes", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], "responses": { "200": { "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } }, "206": { "description": "newPet response", - "schema": { - "$ref": "#/definitions/newPet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } }, - "schemes": [ - "http", - "https" - ], "x-test-header-info": { "name": "x-static-header", "value": "headerValue" - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/pet" + }, + "x-ms-requestBody-index": 0 }, "patch": { - "tags": [ ], + "tags": [], "summary": "", "description": "", "operationId": "patchDefaultResponse", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], "responses": { "default": { "description": "pet", - "schema": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } } }, - "schemes": [ - "http", - "https" - ], "x-test-header-info": { "name": "x-static-header", "value": "headerValue" - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/pet" + }, + "x-ms-requestBody-index": 0 } }, "/streamedpets": { "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "getSameStreamResponse", - "produces": [ - "application/json" - ], "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, - "type": "integer", - "format": "int32" + "schema": { + "type": "integer", + "format": "int32" + } } ], "responses": { "200": { "description": "200 response", - "schema": { - "$ref": "#/definitions/VirtualMachineGetRemoteDesktopFileResponse" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + } } }, "202": { "description": "202 response", - "schema": { - "$ref": "#/definitions/VirtualMachineGetRemoteDesktopFileResponse" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } } }, "patch": { - "tags": [ ], + "tags": [], "summary": "", "description": "", "operationId": "patchDifferentStreamTypesNoContent", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], "responses": { "200": { "description": "pet response", - "schema": { - "$ref": "#/definitions/VirtualMachineGetRemoteDesktopFileResponse" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/VirtualMachineGetRemoteDesktopFileResponse" + } + } } }, "204": { @@ -364,142 +1104,271 @@ }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } }, - "schemes": [ - "http", - "https" - ], "x-test-header-info": { "name": "x-static-header", "value": "headerValue" - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/pet" + }, + "x-ms-requestBody-index": 0 } } }, - "definitions": { - "pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" + "security": [], + "tags": [], + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } } - } - }, - "cat": { - "extends": "pet", - "required": [ - "breed" - ], - "properties": { - "breed": { - "type": "string" - }, - "color": { - "type": "string" + }, + "cat": { + "extends": "pet", + "required": [ + "breed" + ], + "properties": { + "breed": { + "type": "string" + }, + "color": { + "type": "string" + } } - } - }, - "siamese": { - "extends": "cat", - "properties": { - "mood": { - "type": "string" + }, + "siamese": { + "extends": "cat", + "properties": { + "mood": { + "type": "string" + } } - } - }, - "dog": { - "extends": "pet", - "required": [ - "pedigree" - ], - "properties": { - "pedigree": { - "type": "boolean" + }, + "dog": { + "extends": "pet", + "required": [ + "pedigree" + ], + "properties": { + "pedigree": { + "type": "boolean" + } } - } - }, - "newPet": { - "allOf": [ - { - "$ref": "#/definitions/pet" - }, - { - "required": [ - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" + }, + "newPet": { + "allOf": [ + { + "$ref": "#/components/schemas/pet" + }, + { + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } } } + ] + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } } - ] - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" + }, + "VirtualMachineGetRemoteDesktopFileResponse": { + "properties": { + "RemoteDesktopFile": { + "type": "string", + "format": "byte" + } } } }, - "VirtualMachineGetRemoteDesktopFileResponse": { - "properties": { - "RemoteDesktopFile": { - "type": "string", - "format": "byte" + "responses": { + "petResponse": { + "description": " A created or updated pet", + "headers": { + "x-ms-request-id": { + "description": " The request ID", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } } - } - }, - "parameters": { - "petParameter": { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - }, - "responses": { - "petResponse": { - "description": " A created or updated pet", - "schema": { - "$ref": "#/definitions/pet" - }, - "headers": { - "x-ms-request-id": { - "description": " The request ID", - "type": "string" - } + }, + "requestBodies": { + "pet": { + "x-ms-client-name": "PetCreateOrUpdateParameter", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + }, + "description": "A Pet", + "required": true } } - }, - "securityDefinitions": { }, - "security": [ ], - "tags": [ ] + } } \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-no-content.json b/test/Resource/Swagger/swagger-no-content.json index 31017fe..9fa798f 100644 --- a/test/Resource/Swagger/swagger-no-content.json +++ b/test/Resource/Swagger/swagger-no-content.json @@ -1,14 +1,14 @@ -{ - "swagger": "2.0", +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "https://autorestresourcesproxysite.azurewebsites.net:443/BlobConnector" + } + ], "info": { "version": "1.0", "title": "Blob Connector" }, - "host": "autorestresourcesproxysite.azurewebsites.net:443", - "basePath": "/BlobConnector", - "schemes": [ - "https" - ], "paths": { "/Container/Poll": { "get": { @@ -17,56 +17,93 @@ ], "summary": "Poll for blobs present in given Container. Directory-level Polling and filtering of Blobs is also supported. \r\n Deletes Blobs from the Container once they are picked up", "operationId": "BlobConnector_TriggerOnBlobContainer", - "consumes": [ - - ], - "produces": [ - "application/json", - "text/json", - "application/xml", - "text/xml" - ], "parameters": [ { "name": "triggerState", "in": "query", "description": "Specify Trigger State", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "directoryName", "in": "query", "description": "Virtual directory within Container from which we need to poll", "required": false, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "includeRegex", "in": "query", "description": "Include File Mask", "required": false, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "excludeRegex", "in": "query", "description": "Exclude File Mask", "required": false, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "$ref": "#/definitions/MessageDescription" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + } } }, "202": { "description": "Operation is accepted", - "schema": { - "$ref": "#/definitions/MessageDescription" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + } } }, "400": { @@ -89,56 +126,59 @@ ], "summary": "Upload/Update a Blob to the Container", "operationId": "BlobConnector_UploadBlob", - "consumes": [ - "application/json", - "text/json", - "application/xml", - "text/xml", - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json", - "text/json", - "application/xml", - "text/xml" - ], "parameters": [ - { - "name": "blobContentAndDetails", - "in": "body", - "description": "JSON Object containing the Base-64 encoded Blob Content and a name-value pair containing Blob Properties", - "required": true, - "schema": { - "$ref": "#/definitions/MessageDescription" - } - }, { "name": "blobName", "in": "query", "description": "Name of the Uploaded Blob. Required", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "directoryName", "in": "query", "description": "Virtual directory within the container to which Blob should be uploaded. Optional", "required": false, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "forceOverwrite", "in": "query", "description": "If a Blob with the same name already exists, should it be overwritten? Default value : true", "required": false, - "type": "boolean" + "schema": { + "type": "boolean" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "$ref": "#/definitions/BlobDetailsItem" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + } } }, "400": { @@ -151,7 +191,40 @@ "description": "Internal Server Error" } }, - "deprecated": false + "deprecated": false, + "requestBody": { + "x-ms-client-name": "blobContentAndDetails", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + } + }, + "description": "JSON Object containing the Base-64 encoded Blob Content and a name-value pair containing Blob Properties", + "required": true + }, + "x-ms-requestBody-index": 0 } }, "/Container": { @@ -161,39 +234,62 @@ ], "summary": "List all the blobs within the Container", "operationId": "BlobConnector_ListBlobsInContainer", - "consumes": [ - - ], - "produces": [ - "application/json", - "text/json", - "application/xml", - "text/xml" - ], "parameters": [ { "name": "blobDirectoryName", "in": "query", "description": "Name of specific directory within container for which listing must be performed. Optional.", "required": false, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "maxResults", "in": "query", "description": "Maximum number of blobs in the List Returned", "required": false, - "type": "integer", - "format": "int32" + "schema": { + "type": "integer", + "format": "int32" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/BlobDetailsItem" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + } + }, + "text/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + } + }, + "text/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BlobDetailsItem" + } + } } } }, @@ -217,36 +313,50 @@ ], "summary": "Get a specific Blob from the container", "operationId": "BlobConnector_GetBlob", - "consumes": [ - - ], - "produces": [ - "application/json", - "text/json", - "application/xml", - "text/xml" - ], "parameters": [ { "name": "blobName", "in": "query", "description": "Name of the blob to retrieve", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "directoryName", "in": "query", "description": "Virtual directory within the container from which Blob should be retrieved. Optional", "required": false, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "$ref": "#/definitions/MessageDescription" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + } } }, "400": { @@ -267,33 +377,35 @@ ], "summary": "Delete specific Blob from a Container", "operationId": "BlobConnector_DeleteBlob", - "consumes": [ - - ], - "produces": [ - - ], "parameters": [ { "name": "blobName", "in": "query", "description": "Name of the specific blob to delete", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "directoryName", "in": "query", "description": "Virtual directory within the container from which Blob should be deleted. Optional", "required": false, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "$ref": "#/definitions/Void" + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Void" + } + } } }, "400": { @@ -316,26 +428,26 @@ ], "summary": "Create a read-only snapshot of a Specific Blob", "operationId": "BlobConnector_SnapshotBlob", - "consumes": [ - - ], - "produces": [ - - ], "parameters": [ { "name": "blobName", "in": "query", "description": "Name of the specific blob for which snapshot must be created", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "$ref": "#/definitions/MessageDescription" + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/MessageDescription" + } + } } }, "400": { @@ -358,46 +470,54 @@ ], "summary": "Copy a specific Blob to another container within the same storage account", "operationId": "BlobConnector_CopyBlobWithinSameAccount", - "consumes": [ - - ], - "produces": [ - - ], "parameters": [ { "name": "sourceBlobName", "in": "query", "description": "Name of the blob which will be copied", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "destinationContainerName", "in": "query", "description": "Name of the destination container", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "destinationBlobName", "in": "query", "description": "Name of the destination blob. Optional, if not set it will be the same as source blob", "required": false, - "type": "string" + "schema": { + "type": "string" + } } ], "responses": { "200": { "description": "Operation is successful.", - "schema": { - "$ref": "#/definitions/Void" + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Void" + } + } } }, "202": { "description": "Accepted.", - "schema": { - "$ref": "#/definitions/Void" + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Void" + } + } } }, "400": { @@ -414,97 +534,95 @@ } } }, - "definitions": { - "MessageDescription": { - "required": [ - "Content", - "Properties" - ], - "type": "object", - "properties": { - "Content": { - "$ref": "#/definitions/Content" - }, - "Properties": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Object" + "components": { + "schemas": { + "MessageDescription": { + "required": [ + "Content", + "Properties" + ], + "type": "object", + "properties": { + "Content": { + "$ref": "#/components/schemas/Content" + }, + "Properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Object" + } } } - } - }, - "Content": { - "required": [ - "ContentData", - "ContentType", - "ContentTransferEncoding" - ], - "type": "object", - "properties": { - "ContentData": { - "type": "string" - }, - "ContentType": { - "type": "string" - }, - "ContentTransferEncoding": { - "type": "string" + }, + "Content": { + "required": [ + "ContentData", + "ContentType", + "ContentTransferEncoding" + ], + "type": "object", + "properties": { + "ContentData": { + "type": "string" + }, + "ContentType": { + "type": "string" + }, + "ContentTransferEncoding": { + "type": "string" + } } - } - }, - "Object": { - "type": "object", - "properties": { - - } - }, - "BlobDetailsItem": { - "required": [ - "BlobName", - "BlobPath", - "LastModified", - "BlobType", - "ContentType", - "AbsoluteUri", - "BlobSize" - ], - "type": "object", - "properties": { - "BlobName": { - "description": "Blob Name", - "type": "string" - }, - "BlobPath": { - "description": "Blob Path", - "type": "string" - }, - "LastModified": { - "description": "Last Modified", - "type": "string" - }, - "BlobType": { - "description": "Blob Type", - "type": "string" - }, - "ContentType": { - "description": "Content Type", - "type": "string" - }, - "AbsoluteUri": { - "description": "Absolute Uri", - "type": "string" - }, - "BlobSize": { - "format": "int64", - "description": "Blob Size", - "type": "integer" + }, + "Object": { + "type": "object", + "properties": {} + }, + "BlobDetailsItem": { + "required": [ + "BlobName", + "BlobPath", + "LastModified", + "BlobType", + "ContentType", + "AbsoluteUri", + "BlobSize" + ], + "type": "object", + "properties": { + "BlobName": { + "description": "Blob Name", + "type": "string" + }, + "BlobPath": { + "description": "Blob Path", + "type": "string" + }, + "LastModified": { + "description": "Last Modified", + "type": "string" + }, + "BlobType": { + "description": "Blob Type", + "type": "string" + }, + "ContentType": { + "description": "Content Type", + "type": "string" + }, + "AbsoluteUri": { + "description": "Absolute Uri", + "type": "string" + }, + "BlobSize": { + "format": "int64", + "description": "Blob Size", + "type": "integer" + } } - } - }, - "Void": { - "type": "object", - "properties": { - + }, + "Void": { + "type": "object", + "properties": {} } } } diff --git a/test/Resource/Swagger/swagger-optional-params.json b/test/Resource/Swagger/swagger-optional-params.json index 258cf97..8d15692 100644 --- a/test/Resource/Swagger/swagger-optional-params.json +++ b/test/Resource/Swagger/swagger-optional-params.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Optional Parameter test spec", "description": "Test correct generation of optional method parameters", "version": "1.0" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/params": { "get": { @@ -23,61 +21,79 @@ "name": "intParam", "in": "query", "description": "The maximum number of results to return.", - "type": "integer" + "schema": { + "type": "integer" + } }, - { + { "name": "longParam", "in": "query", "description": "The maximum number of results to return.", - "type": "integer", - "format": "int64" + "schema": { + "type": "integer", + "format": "int64" + } }, { "name": "floatParam", "in": "query", "description": "The maximum number of results to return.", - "type": "number", - "format": "float" + "schema": { + "type": "number", + "format": "float" + } }, { "name": "doubleParam", "in": "query", "description": "The maximum number of results to return.", - "type": "number", - "format": "double" + "schema": { + "type": "number", + "format": "double" + } }, { "name": "byteParam", "in": "query", "description": "The maximum number of results to return.", - "type": "string", - "format": "byte" + "schema": { + "type": "string", + "format": "byte" + } }, { "name": "booleanParam", "in": "query", "description": "The maximum number of results to return.", - "type": "boolean" + "schema": { + "type": "boolean" + } }, { "name": "dateParam", "in": "query", "description": "The maximum number of results to return.", - "type": "string", - "format": "date" + "schema": { + "type": "string", + "format": "date" + } }, { "name": "datetimeParam", "in": "query", "description": "The maximum number of results to return.", - "type": "string", - "format": "date-time" + "schema": { + "type": "string", + "format": "date-time" + } }, - { + { "name": "api-version", "in": "query", "description": "API version", - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -86,18 +102,26 @@ "responses": { "200": { "description": "A list of widgets", - "schema": { - "type": "array", - "description": "A list of widgets", - "items": { - "$ref": "#/definitions/Widget" + "content": { + "application/json": { + "schema": { + "type": "array", + "description": "A list of widgets", + "items": { + "$ref": "#/components/schemas/Widget" + } + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -114,61 +138,79 @@ "in": "path", "description": "The id of the widget to get", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "intParam", "in": "query", "description": "The maximum number of results to return.", - "type": "integer" + "schema": { + "type": "integer" + } }, - { + { "name": "longParam", "in": "query", "description": "The maximum number of results to return.", - "type": "integer", - "format": "int64" + "schema": { + "type": "integer", + "format": "int64" + } }, { "name": "floatParam", "in": "query", "description": "The maximum number of results to return.", - "type": "number", - "format": "float" + "schema": { + "type": "number", + "format": "float" + } }, { "name": "doubleParam", "in": "query", "description": "The maximum number of results to return.", - "type": "number", - "format": "double" + "schema": { + "type": "number", + "format": "double" + } }, { "name": "byteParam", "in": "query", "description": "The maximum number of results to return.", - "type": "string", - "format": "byte" + "schema": { + "type": "string", + "format": "byte" + } }, { "name": "booleanParam", "in": "query", "description": "The maximum number of results to return.", - "type": "boolean" + "schema": { + "type": "boolean" + } }, { "name": "dateParam", "in": "query", "description": "The maximum number of results to return.", - "type": "string", - "format": "date" + "schema": { + "type": "string", + "format": "date" + } }, { "name": "datetimeParam", "in": "query", "description": "The maximum number of results to return.", - "type": "string", - "format": "date-time" + "schema": { + "type": "string", + "format": "date-time" + } } ], "tags": [ @@ -177,58 +219,68 @@ "responses": { "200": { "description": "The returned product", - "schema": { - "$ref": "#/definitions/Widget" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Widget" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } } } }, - "definitions": { - "Widget": { - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people." - }, - "image": { - "type": "string", - "description": "Image URL representing the product." + "components": { + "schemas": { + "Widget": { + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people." + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } } - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-polymorphism.json b/test/Resource/Swagger/swagger-polymorphism.json index f0fc15b..74d4afe 100644 --- a/test/Resource/Swagger/swagger-polymorphism.json +++ b/test/Resource/Swagger/swagger-polymorphism.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Polymorphism PetStore", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/getpolymorphicpets": { "get": { @@ -21,14 +19,22 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Pet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -37,139 +43,181 @@ "operationId": "CreateOrUpdatePolymorphicPets", "summary": "Product Types", "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "schema": { - "$ref": "#/definitions/Pet" - } - } - ], "responses": { "200": { "description": "A list of caches" }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "PetCreateOrUpdateParameter", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "description": "A Pet" + }, + "x-ms-requestBody-index": 0 } } }, - "definitions": { - "Pet": { - "discriminator": "dtype", - "required": [ - "dtype" - ], - "properties": { - "id": { - "type": "string", - "description": "Id." + "components": { + "schemas": { + "Pet": { + "discriminator": { + "propertyName": "dtype" }, - "description": { - "type": "string", - "description": "Description of a pet." - }, - "dtype": { - "type": "string" + "required": [ + "dtype" + ], + "properties": { + "id": { + "type": "string", + "description": "Id." + }, + "description": { + "type": "string", + "description": "Description of a pet." + }, + "dtype": { + "type": "string" + } } - } - }, - "Cat": { - "allOf": [ { "$ref": "#/definitions/Pet" } ], - "properties": { - "color": { - "type": "string", - "description": "cat color" + }, + "Cat": { + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + } + ], + "properties": { + "color": { + "type": "string", + "description": "cat color" + } } - } - }, - "Seamise": { - "allOf": [ { "$ref": "#/definitions/Cat" } ], - "properties": { - "length": { - "type": "integer", - "description": "cat length" + }, + "Seamise": { + "allOf": [ + { + "$ref": "#/components/schemas/Cat" + } + ], + "properties": { + "length": { + "type": "integer", + "description": "cat length" + } } - } - }, - "Burmese": { - "allOf": [ { "$ref": "#/definitions/Seamise" } ], - "properties": { - "nickName": { - "type": "integer", - "description": "cat nick name" + }, + "Burmese": { + "allOf": [ + { + "$ref": "#/components/schemas/Seamise" + } + ], + "properties": { + "nickName": { + "type": "integer", + "description": "cat nick name" + } } - } - }, - "Himalayan": { - "allOf": [ { "$ref": "#/definitions/Seamise" } ], - "properties": { - "hairLength": { - "type": "integer", - "description": "cat hair length" + }, + "Himalayan": { + "allOf": [ + { + "$ref": "#/components/schemas/Seamise" + } + ], + "properties": { + "hairLength": { + "type": "integer", + "description": "cat hair length" + } } - } - }, - "Persian": { - "allOf": [ { "$ref": "#/definitions/Cat" } ], - "properties": { - "size": { - "type": "integer", - "description": "cat size" + }, + "Persian": { + "allOf": [ + { + "$ref": "#/components/schemas/Cat" + } + ], + "properties": { + "size": { + "type": "integer", + "description": "cat size" + } } - } - }, - "Dog": { - "id": "Dog", - "allOf": [ { "$ref": "#/definitions/Pet" } ], - "properties": { - "name": { - "type": "string", - "description": "dog name" + }, + "Dog": { + "id": "Dog", + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + } + ], + "properties": { + "name": { + "type": "string", + "description": "dog name" + } } - } - }, - "Horse": { - "id": "Horse", - "allOf": [ { "$ref": "#/definitions/Pet" } ], - "properties": { - "breed": { - "type": "string", - "description": "horse breed" + }, + "Horse": { + "id": "Horse", + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + } + ], + "properties": { + "breed": { + "type": "string", + "description": "horse breed" + } } - } - }, - "Lizard": { - "x-ms-discriminator-value": "lzd", - "allOf": [ { "$ref": "#/definitions/Pet" } ], - "properties": { - "tailSize": { - "type": "number", - "format": "float", - "description": "length of tail" + }, + "Lizard": { + "x-ms-discriminator-value": "lzd", + "allOf": [ + { + "$ref": "#/components/schemas/Pet" + } + ], + "properties": { + "tailSize": { + "type": "number", + "format": "float", + "description": "length of tail" + } } - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-recursive-type.json b/test/Resource/Swagger/swagger-recursive-type.json index 568d5f8..2c5d9d6 100644 --- a/test/Resource/Swagger/swagger-recursive-type.json +++ b/test/Resource/Swagger/swagger-recursive-type.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Recursive Types API", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { "post": { @@ -24,29 +22,26 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" - }, - { - "name": "body", - "in": "body", - "description": "API body mody.", - "required": false, "schema": { - "$ref": "#/definitions/Product" + "type": "string" } } ], @@ -56,51 +51,73 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + }, + "description": "API body mody." + }, + "x-ms-requestBody-index": 3 } } }, - "definitions": { - "Product": { - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "parentProduct": { - "$ref": "#/definitions/Product" - }, - "innerProducts": { - "type": "array", - "items": { - "$ref": "#/definitions/Product" + "components": { + "schemas": { + "Product": { + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "parentProduct": { + "$ref": "#/components/schemas/Product" + }, + "innerProducts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Product" + } } } - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } } } } } - } +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-ref-allOf-inheritance.json b/test/Resource/Swagger/swagger-ref-allOf-inheritance.json index a72247c..5f975fa 100644 --- a/test/Resource/Swagger/swagger-ref-allOf-inheritance.json +++ b/test/Resource/Swagger/swagger-ref-allOf-inheritance.json @@ -1,25 +1,17 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "RedisManagementClient", "description": "A sample model for testing that swagger references and allOf gets understood by the modeler properly", "version": "1.0.0" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json", - "text/json" - ], - "produces": [ - "application/json", - "text/json" - ], - "securityDefinitions": { }, - "security": [ ], - "tags": [ ], + "security": [], + "tags": [], "paths": { "providers/Microsoft.Cache/Redis/{name}": { "put": { @@ -30,251 +22,273 @@ "name": "name", "in": "path", "required": true, - "type": "string", - "description": "" - }, - { - "name": "parameters", - "in": "body", - "required": true, + "description": "", "schema": { - "$ref": "#/definitions/RedisCreateOrUpdateParameters" - }, - "description": "Parameters supplied to the CreateOrUpdate redis operation." + "type": "string" + } } ], "responses": { "201": { - "description": "", - "schema": { - "$ref": "#/definitions/Resource" + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Resource" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/Resource" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "parameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RedisCreateOrUpdateParameters" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/RedisCreateOrUpdateParameters" + } + } + }, + "description": "Parameters supplied to the CreateOrUpdate redis operation.", + "required": true + }, + "x-ms-requestBody-index": 1 } } }, - "definitions": { - "Sku": { - "properties": { - "name": { - "type": "string", - "description": "", - "enum": [ - "Basic", - "Standard", - "Premium" - ], - "x-ms-enum": { - "name": "SkuName", - "modelAsString": true + "components": { + "schemas": { + "Sku": { + "properties": { + "name": { + "type": "string", + "description": "", + "enum": [ + "Basic", + "Standard", + "Premium" + ], + "x-ms-enum": { + "name": "SkuName", + "modelAsString": true + } + }, + "family": { + "type": "string", + "description": "", + "enum": [ + "C", + "P" + ], + "x-ms-enum": { + "name": "SkuFamily", + "modelAsString": true + } + }, + "capacity": { + "type": "integer", + "format": "int32", + "description": "" } }, - "family": { - "type": "string", - "description": "", - "enum": [ - "C", - "P" - ], - "x-ms-enum": { - "name": "SkuFamily", - "modelAsString": true + "required": [ + "name", + "family", + "capacity" + ], + "description": "Sku parameters supplied to the create redis operation." + }, + "RedisProperties": { + "properties": { + "sku": { + "$ref": "#/components/schemas/Sku", + "description": "" + }, + "redisConfiguration": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "" + }, + "enableNonSslPort": { + "type": "boolean", + "description": "" + }, + "tenantSettings": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "" + }, + "shardCount": { + "type": "integer", + "format": "int32", + "description": "" + }, + "subnetId": { + "type": "string", + "description": "" + }, + "staticIP": { + "type": "string", + "description": "" } }, - "capacity": { - "type": "integer", - "format": "int32", - "description": "" - } + "required": [ + "sku" + ], + "description": "'RedisProperties' - Parameters supplied to CreateOrUpdate redis operation." }, - "required": [ - "name", - "family", - "capacity" - ], - "description": "Sku parameters supplied to the create redis operation." - }, - "RedisProperties": { - "properties": { - "sku": { - "$ref": "#/definitions/Sku", - "description": "" - }, - "redisConfiguration": { - "type": "object", - "additionalProperties": { - "type": "string" + "Resource": { + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id" }, - "description": "" - }, - "enableNonSslPort": { - "type": "boolean", - "description": "" - }, - "tenantSettings": { - "type": "object", - "additionalProperties": { - "type": "string" + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" }, - "description": "" - }, - "shardCount": { - "type": "integer", - "format": "int32", - "description": "" - }, - "subnetId": { - "type": "string", - "description": "" + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } }, - "staticIP": { - "type": "string", - "description": "" - } + "description": "''Resource' - common resource information", + "required": [ + "location" + ], + "x-ms-azure-resource": true }, - "required": [ - "sku" - ], - "description": "'RedisProperties' - Parameters supplied to CreateOrUpdate redis operation." - }, - "Resource": { - "properties": { - "id": { - "readOnly": true, - "type": "string", - "description": "Resource Id" - }, - "name": { - "readOnly": true, - "type": "string", - "description": "Resource name" - }, - "type": { - "readOnly": true, - "type": "string", - "description": "Resource type" - }, - "location": { - "type": "string", - "description": "Resource location" + "RedisCreateOrUpdateParameters": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/components/schemas/RedisProperties", + "description": "'RedisCreateOrUpdateParameters.properties' - Redis cache properties." + } }, - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Resource tags" - } + "required": [ + "properties" + ], + "allOf": [ + { + "$ref": "#/components/schemas/Resource" + } + ], + "description": "'RedisCreateOrUpdateParameters' - Parameters supplied to the CreateOrUpdate Redis operation." }, - "description": "''Resource' - common resource information", - "required": [ - "location" - ], - "x-ms-azure-resource": true - }, - "RedisCreateOrUpdateParameters": { - "properties": { + "RedisAccessKeys": { "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/RedisProperties", - "description": "'RedisCreateOrUpdateParameters.properties' - Redis cache properties." - } - }, - "required": [ - "properties" - ], - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "'RedisCreateOrUpdateParameters' - Parameters supplied to the CreateOrUpdate Redis operation." - }, - "RedisAccessKeys": { - "properties": { - "primaryKey": { - "type": "string", - "description": "" + "primaryKey": { + "type": "string", + "description": "" + }, + "secondaryKey": { + "type": "string", + "description": "" + } }, - "secondaryKey": { - "type": "string", - "description": "" - } + "description": "'RedisAccessKeys' - Redis cache access keys." }, - "description": "'RedisAccessKeys' - Redis cache access keys." - }, - "RedisReadableProperties": { - "properties": { - "provisioningState": { - "type": "string", - "description": "provisioning status" - }, - "hostName": { - "type": "string", - "description": "" - }, - "port": { - "type": "integer", - "format": "int32", - "description": "" + "RedisReadableProperties": { + "properties": { + "provisioningState": { + "type": "string", + "description": "provisioning status" + }, + "hostName": { + "type": "string", + "description": "" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "" + }, + "sslPort": { + "type": "integer", + "format": "int32", + "description": "" + } }, - "sslPort": { - "type": "integer", - "format": "int32", - "description": "" - } - }, - "allOf": [ - { - "$ref": "#/definitions/RedisProperties" - } - ], - "description": "'RedisReadableProperties' - Parameters describing a redis instance" - }, - "RedisReadablePropertiesWithAccessKey": { - "properties": { - "accessKeys": { - "$ref": "#/definitions/RedisAccessKeys", - "description": "Redis cache access keys." - } + "allOf": [ + { + "$ref": "#/components/schemas/RedisProperties" + } + ], + "description": "'RedisReadableProperties' - Parameters describing a redis instance" }, - "allOf": [ - { - "$ref": "#/definitions/RedisReadableProperties" - } - ], - "description": "'RedisReadablePropertiesWithAccessKey' - Access Keys in addition to RedisReadableProperties" - }, - "RedisResourceWithAccessKey": { - "properties": { + "RedisReadablePropertiesWithAccessKey": { "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/RedisReadablePropertiesWithAccessKey", - "description": "'RedisResourceWithAccessKey.properties' Redis cache properties" - } + "accessKeys": { + "$ref": "#/components/schemas/RedisAccessKeys", + "description": "Redis cache access keys." + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/RedisReadableProperties" + } + ], + "description": "'RedisReadablePropertiesWithAccessKey' - Access Keys in addition to RedisReadableProperties" }, - "allOf": [ - { - "$ref": "#/definitions/RedisResource" - } - ], - "description": "'RedisResourceWithAccessKey' - A redis item in CreateOrUpdate Operation response." - }, - "RedisResource": { - "properties": { + "RedisResourceWithAccessKey": { "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/RedisReadableProperties", - "description": "'RedisResource.properties' - Redis cache properties" - } + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/components/schemas/RedisReadablePropertiesWithAccessKey", + "description": "'RedisResourceWithAccessKey.properties' Redis cache properties" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/RedisResource" + } + ], + "description": "'RedisResourceWithAccessKey' - A redis item in CreateOrUpdate Operation response." }, - "allOf": [ - { - "$ref": "#/definitions/Resource" - } - ], - "description": "'RedisResource' - A redis resource" + "RedisResource": { + "properties": { + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/components/schemas/RedisReadableProperties", + "description": "'RedisResource.properties' - Redis cache properties" + } + }, + "allOf": [ + { + "$ref": "#/components/schemas/Resource" + } + ], + "description": "'RedisResource' - A redis resource" + } } } } \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-response-headers.json b/test/Resource/Swagger/swagger-response-headers.json index b0c1d2c..41e4060 100644 --- a/test/Resource/Swagger/swagger-response-headers.json +++ b/test/Resource/Swagger/swagger-response-headers.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Microsoft Azure Redis Cache Management API", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups": { "get": { @@ -20,50 +18,72 @@ "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", "parameters": [ { - "$ref": "#/parameters/SubscriptionIdParamterer" + "$ref": "#/components/parameters/SubscriptionIdParamterer" } ], "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" - }, "headers": { "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", - "type": "integer" + "schema": { + "type": "integer" + } }, "X-Rate-Limit-Remaining": { "description": "The number of remaining requests in the current period", - "type": "integer" + "schema": { + "type": "integer" + } }, "X-Rate-Seconds": { "description": "The number of seconds left in the current period", - "type": "string" + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } } } }, "201": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" - }, "headers": { "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", - "type": "integer" + "schema": { + "type": "integer" + } }, "X-Rate-Limit-Remaining": { "description": "The number of remaining requests in the current period", - "type": "integer" + "schema": { + "type": "integer" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -74,106 +94,130 @@ "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", "parameters": [ { - "$ref": "#/parameters/SubscriptionIdParamterer" - }, - { - "name": "body", - "in": "body", - "schema": { - "$ref": "#/definitions/Product" - } + "$ref": "#/components/parameters/SubscriptionIdParamterer" } ], "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" - }, "headers": { "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", - "type": "integer" + "schema": { + "type": "integer" + } }, "X-Rate-Limit-Remaining": { "description": "The number of remaining requests in the current period", - "type": "integer" + "schema": { + "type": "integer" + } }, "X-Rate-Seconds": { "description": "The number of seconds left in the current period", - "type": "string" + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + } + }, + "x-ms-requestBody-index": 1 } } }, - "definitions": { - "Product": { - "description": "The product documentation.", - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people." + "components": { + "schemas": { + "Product": { + "description": "The product documentation.", + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people." + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } }, - "image": { - "type": "string", - "description": "Image URL representing the product." + "example": { + "name": "Puma", + "id": 1 } }, - "example": { - "name": "Puma", - "id": 1 + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } + } } }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "schema": { "type": "string" - }, - "fields": { + } + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "schema": { "type": "string" } } } - }, - "parameters": { - "SubscriptionIdParamterer": { - "name": "subscriptionId", - "in": "path", - "description": "Subscription ID.", - "required": true, - "type": "string" - }, - "ApiVersionParameter": { - "name": "apiVersion", - "in": "path", - "description": "API ID.", - "required": true, - "type": "string" - } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-simple-spec.json b/test/Resource/Swagger/swagger-simple-spec.json index 7fc1641..66d434e 100644 --- a/test/Resource/Swagger/swagger-simple-spec.json +++ b/test/Resource/Swagger/swagger-simple-spec.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Microsoft Azure Redis Cache Management API", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { "get": { @@ -20,17 +18,19 @@ "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", "parameters": [ { - "$ref": "#/parameters/SubscriptionIdParamterer" + "$ref": "#/components/parameters/SubscriptionIdParamterer" }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { - "$ref": "#/parameters/ApiVersionParameter" + "$ref": "#/components/parameters/ApiVersionParameter" } ], "tags": [ @@ -39,14 +39,22 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } @@ -61,21 +69,27 @@ "in": "path", "description": "Subscription ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } }, { "name": "apiVersion", "in": "path", "description": "API ID.", "required": true, - "type": "string" + "schema": { + "type": "string" + } } ], "tags": [ @@ -84,94 +98,110 @@ "responses": { "204": { "description": "A list of caches", - "examples": { + "content": { "application/json": { - "id": 9, - "category": { - "name": "domestic" - }, - "name": "monster", - "tags": [ - { - "name": "for sale" + "examples": { + "response": { + "value": { + "id": 9, + "category": { + "name": "domestic" + }, + "name": "monster", + "tags": [ + { + "name": "for sale" + } + ], + "status": "alive" + } } - ], - "status": "alive" + } } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } } } }, - "definitions": { - "Product": { - "title": "The product title.", - "description": "The product documentation.", - "properties": { - "product_id": { - "type": "string", - "title": "A product id.", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people.", - "default": "100" + "components": { + "schemas": { + "Product": { + "title": "The product title.", + "description": "The product documentation.", + "properties": { + "product_id": { + "type": "string", + "title": "A product id.", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people.", + "default": "100" + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } }, - "image": { - "type": "string", - "description": "Image URL representing the product." + "example": { + "name": "Puma", + "id": 1 } }, - "example": { - "name": "Puma", - "id": 1 + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } + } } }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "schema": { "type": "string" - }, - "fields": { + } + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "schema": { "type": "string" } } } - }, - "parameters": { - "SubscriptionIdParamterer": { - "name": "subscriptionId", - "in": "path", - "description": "Subscription ID.", - "required": true, - "type": "string" - }, - "ApiVersionParameter": { - "name": "apiVersion", - "in": "path", - "description": "API ID.", - "required": true, - "type": "string" - } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-simple-spec.yaml b/test/Resource/Swagger/swagger-simple-spec.yaml index 51cd17e..1a34c85 100644 --- a/test/Resource/Swagger/swagger-simple-spec.yaml +++ b/test/Resource/Swagger/swagger-simple-spec.yaml @@ -1,128 +1,205 @@ -swagger: '2.0' -info: - title: Microsoft Azure Redis Cache Management API - description: Some cool documentation. - version: 2014-04-01-preview -host: management.azure.com -schemes: - - https -basePath: / -produces: - - application/json -consumes: - - application/json -paths: - '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}': - get: - operationId: list - summary: Product Types - description: >- - The Products endpoint returns information about the Uber products - offered at a given location. The response includes the display name and - other details about each product, and lists the products in the proper - display order. - parameters: - - $ref: '#/parameters/SubscriptionIdParamterer' - - name: resourceGroupName - in: path - description: Resource Group ID. - required: true - type: string - - $ref: '#/parameters/ApiVersionParameter' - tags: - - Redis - responses: - '200': - description: A list of caches - schema: - $ref: '#/definitions/Product' - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' - post: - operationId: reset - summary: Resets products - description: Resets products. - parameters: - - name: subscriptionId - in: path - description: Subscription ID. - required: true - type: string - - name: resourceGroupName - in: path - description: Resource Group ID. - required: true - type: string - - name: apiVersion - in: path - description: API ID. - required: true - type: string - tags: - - Redis - responses: - '204': - description: A list of caches - examples: - application/json: - id: 9 - category: - name: domestic - name: monster - tags: - - name: for sale - status: alive - default: - description: Unexpected error - schema: - $ref: '#/definitions/Error' -definitions: - Product: - description: The product documentation. - properties: - product_id: - type: string - description: >- - Unique identifier representing a specific product for a given latitude - & longitude. For example, uberX in San Francisco will have a different - product_id than uberX in Los Angeles. - description: - type: string - description: Description of product. - display_name: - type: string - description: Display name of product. - capacity: - type: string - description: 'Capacity of product. For example, 4 people.' - default: '100' - image: - type: string - description: Image URL representing the product. - example: - name: Puma - id: 1 - Error: - properties: - code: - type: integer - format: int32 - message: - type: string - fields: - type: string -parameters: - SubscriptionIdParamterer: - name: subscriptionId - in: path - description: Subscription ID. - required: true - type: string - ApiVersionParameter: - name: apiVersion - in: path - description: API ID. - required: true - type: string +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "paths": { + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { + "get": { + "operationId": "list", + "summary": "Product Types", + "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", + "parameters": [ + { + "$ref": "#/components/parameters/SubscriptionIdParamterer" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "Resource Group ID.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "$ref": "#/components/parameters/ApiVersionParameter" + } + ], + "tags": [ + "Redis" + ], + "responses": { + "200": { + "description": "A list of caches", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + }, + "post": { + "operationId": "reset", + "summary": "Resets products", + "description": "Resets products.", + "parameters": [ + { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "Resource Group ID.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Redis" + ], + "responses": { + "204": { + "description": "A list of caches", + "content": { + "application/json": { + "examples": { + "response": { + "value": { + "id": 9, + "category": { + "name": "domestic" + }, + "name": "monster", + "tags": [ + { + "name": "for sale" + } + ], + "status": "alive" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Product": { + "description": "The product documentation.", + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people.", + "default": "100" + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } + }, + "example": { + "name": "Puma", + "id": 1 + } + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "fields": { + "type": "string" + } + } + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "schema": { + "type": "string" + } + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "schema": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-streaming.json b/test/Resource/Swagger/swagger-streaming.json index 457b925..cbdb92f 100644 --- a/test/Resource/Swagger/swagger-streaming.json +++ b/test/Resource/Swagger/swagger-streaming.json @@ -1,13 +1,14 @@ -{ - "swagger": "2.0", +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://http://autorestresourcesproxysite.azurewebsites.net/Autorest.HelloWorld/" + } + ], "info": { "version": "1.0.13", "title": "Swagger Stream Store" }, - "host": "http://autorestresourcesproxysite.azurewebsites.net/Autorest.HelloWorld", - "schemes": [ - "http" - ], "paths": { "/values/formDate": { "post": { @@ -15,60 +16,78 @@ "Values" ], "operationId": "GetWithStreamFormData", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "image/jpeg" - ], - "parameters": [ - { - "name": "fileContent", - "description": "file to upload", - "required": true, - "type": "file", - "in": "formData" - } - ], "responses": { "200": { "description": "OK", - "schema": { - "type": "file" + "content": { + "image/jpeg": { + "schema": { + "type": "file" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "fileContent", + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "fileContent": { + "description": "file to upload", + "type": "file" + } + }, + "required": [ + "fileContent" + ] + } + } + } + }, + "x-ms-requestBody-index": 0 }, "get": { "tags": [ "Values" ], "operationId": "PostWithByteArrayFormData", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "image/jpeg" - ], - "parameters": [ - { - "name": "fileContent", - "description": "file to upload", - "required": true, - "type": "string", - "format": "byte", - "in": "formData" - } - ], "responses": { "200": { "description": "OK", - "schema": { - "type": "string", - "format": "byte" + "content": { + "image/jpeg": { + "schema": { + "type": "string", + "format": "byte" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "fileContent", + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "fileContent": { + "description": "file to upload", + "type": "string", + "format": "byte" + } + }, + "required": [ + "fileContent" + ] + } + } + } + }, + "x-ms-requestBody-index": 0 } }, "/values": { @@ -77,15 +96,15 @@ "Values" ], "operationId": "GetWithStream", - "consumes": [], - "produces": [ - "image/jpeg" - ], "responses": { "200": { "description": "OK", - "schema": { - "type": "file" + "content": { + "image/jpeg": { + "schema": { + "type": "file" + } + } } } } @@ -95,20 +114,20 @@ "Values" ], "operationId": "PostWithByteArray", - "consumes": [], - "produces": [ - "image/jpeg" - ], "responses": { "200": { "description": "OK", - "schema": { - "type": "string", - "format": "byte" + "content": { + "image/jpeg": { + "schema": { + "type": "string", + "format": "byte" + } + } } } } } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-validation.json b/test/Resource/Swagger/swagger-validation.json index 7ec72a1..34f57d6 100644 --- a/test/Resource/Swagger/swagger-validation.json +++ b/test/Resource/Swagger/swagger-validation.json @@ -1,17 +1,15 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://management.azure.com/" + } + ], "info": { "title": "Swagger With Validation", "description": "Some cool documentation.", "version": "2014-04-01-preview" }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "basePath": "/", - "produces": [ "application/json" ], - "consumes": [ "application/json" ], "paths": { "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/{id}/Redis?api-version={apiVersion}": { "get": { @@ -20,58 +18,70 @@ "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", "parameters": [ { - "$ref": "#/parameters/SubscriptionIdParamterer" + "$ref": "#/components/parameters/SubscriptionIdParamterer" }, { "name": "resourceGroupName", "in": "path", "description": "Resource Group Name.", "required": true, - "type": "string", - "maxLength": 10, - "minLength": 3, - "pattern": "[a-zA-Z0-9]+", - "multipleOf": 10, - "maximum": 1000, - "minimum": 100, - "minItems": 1, - "maxItems": 1, - "uniqueItems": true + "schema": { + "type": "string", + "minimum": 100, + "maximum": 1000, + "minLength": 3, + "maxLength": 10, + "multipleOf": 10, + "minItems": 1, + "maxItems": 1, + "uniqueItems": true, + "pattern": "[a-zA-Z0-9]+" + } }, { "name": "id", "in": "path", "description": "Resource Group ID.", "required": true, - "type": "integer", - "multipleOf": 10, - "maximum": 1000, - "minimum": 100, - "minItems": 1, - "maxItems": 1, - "uniqueItems": true, - "minLength": 1, - "maxLength": 1, - "pattern": "[0-9]+" + "schema": { + "type": "integer", + "minimum": 100, + "maximum": 1000, + "minLength": 1, + "maxLength": 1, + "multipleOf": 10, + "minItems": 1, + "maxItems": 1, + "uniqueItems": true, + "pattern": "[0-9]+" + } }, { - "$ref": "#/parameters/ApiVersionParameter" + "$ref": "#/components/parameters/ApiVersionParameter" }, { "name": "myintconst", "in": "query", "description": "Constant query param.", "required": true, - "type": "integer", - "enum": [ 0 ] + "schema": { + "type": "integer", + "enum": [ + 0 + ] + } }, { "name": "mystrconst", "in": "query", "description": "Constant query param.", "required": true, - "type": "string", - "enum": [ "constant" ] + "schema": { + "type": "string", + "enum": [ + "constant" + ] + } } ], "tags": [ @@ -80,134 +90,161 @@ "responses": { "200": { "description": "A list of caches", - "schema": { - "$ref": "#/definitions/Product" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } } }, "default": { "description": "Unexpected error", - "schema": { - "$ref": "#/definitions/Error" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } } } } } } }, - "definitions": { - "Product": { - "description": "The product documentation.", - "required": [ "myintconst", "mystrconst", "RefStrEnumRequiredConstant", "RefIntEnumRequiredConstant" ], - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_names": { - "type": "array", - "items": { + "components": { + "schemas": { + "Product": { + "description": "The product documentation.", + "required": [ + "myintconst", + "mystrconst", + "RefStrEnumRequiredConstant", + "RefIntEnumRequiredConstant" + ], + "properties": { + "product_id": { + "type": "string", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_names": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Display names of product.", + "maxItems": 6, + "uniqueItems": true, + "minItems": 0, + "multipleOf": 10, + "maximum": 1000, + "minimum": 100, + "minLength": 1, + "maxLength": 1, + "pattern": "[0-9]+" + }, + "capacity": { + "type": "integer", + "description": "Capacity of product. For example, 4 people.", + "exclusiveMinimum": true, + "exclusiveMaximum": true, + "maximum": 100, + "minimum": 0 + }, + "image": { + "type": "string", + "description": "Image URL representing the product.", + "pattern": "http://\\w+" + }, + "myintconst": { + "type": "integer", + "description": "Constant int.", + "enum": [ + 0 + ] + }, + "mystrconst": { + "type": "string", + "description": "Constant string.", + "enum": [ + "constant" + ] + }, + "RefStrEnumRequiredConstant": { + "$ref": "#/components/schemas/RefStrEnum", + "description": "RefStrEnumRequiredConstant Description." + }, + "RefIntEnumRequiredConstant": { + "$ref": "#/components/schemas/RefIntEnum", + "description": "RefIntEnumRequiredConstant Description." + }, + "RefStrEnum": { + "$ref": "#/components/schemas/RefStrEnum", + "description": "RefStrEnumRequiredConstant Description." + }, + "RefIntEnum": { + "$ref": "#/components/schemas/RefIntEnum", + "description": "RefIntEnumRequiredConstant Description." + }, + "example": { + "name": "Puma", + "id": 1 + } + } + }, + "Error": { + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { "type": "string" }, - "description": "Display names of product.", - "maxItems": 6, - "uniqueItems": true, - "minItems": 0, - "multipleOf": 10, - "maximum": 1000, - "minimum": 100, - "minLength": 1, - "maxLength": 1, - "pattern": "[0-9]+" - }, - "capacity": { - "type": "integer", - "description": "Capacity of product. For example, 4 people.", - "exclusiveMinimum": true, - "exclusiveMaximum": true, - "maximum": 100, - "minimum": 0 - }, - "image": { - "type": "string", - "description": "Image URL representing the product.", - "pattern": "http://\\w+" - }, - "myintconst": { - "type": "integer", - "description": "Constant int.", - "enum": [ 0 ] - }, - "mystrconst": { - "type": "string", - "description": "Constant string.", - "enum": [ "constant" ] - }, - "RefStrEnumRequiredConstant": { - "$ref": "#/definitions/RefStrEnum", - "description": "RefStrEnumRequiredConstant Description." - }, - "RefIntEnumRequiredConstant": { - "$ref": "#/definitions/RefIntEnum", - "description": "RefIntEnumRequiredConstant Description." - }, - "RefStrEnum": { - "$ref": "#/definitions/RefStrEnum", - "description": "RefStrEnumRequiredConstant Description." - }, - "RefIntEnum": { - "$ref": "#/definitions/RefIntEnum", - "description": "RefIntEnumRequiredConstant Description." - }, - "example": { - "name": "Puma", - "id": 1 + "fields": { + "type": "string" + } } + }, + "RefStrEnum": { + "type": "string", + "enum": [ + "ReferenceEnum1" + ], + "description": "RefStrEnum Description." + }, + "RefIntEnum": { + "type": "integer", + "enum": [ + 0 + ], + "description": "RefIntEnum Description." } }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "schema": { "type": "string" } + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "query", + "description": "API ID.", + "required": true, + "schema": { + "type": "string", + "pattern": "\\d{2}-\\d{2}-\\d{4}" + } } - }, - "RefStrEnum": { - "type": "string", - "enum": [ "ReferenceEnum1" ], - "description": "RefStrEnum Description." - }, - "RefIntEnum": { - "type": "integer", - "enum": [ 0 ], - "description": "RefIntEnum Description." - } - }, - "parameters": { - "SubscriptionIdParamterer": { - "name": "subscriptionId", - "in": "path", - "description": "Subscription ID.", - "required": true, - "type": "string" - }, - "ApiVersionParameter": { - "name": "apiVersion", - "in": "query", - "description": "API ID.", - "required": true, - "type": "string", - "pattern": "\\d{2}-\\d{2}-\\d{4}" } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-x-ms-code-generation-settings.json b/test/Resource/Swagger/swagger-x-ms-code-generation-settings.json index c8e9394..4b2b1ca 100644 --- a/test/Resource/Swagger/swagger-x-ms-code-generation-settings.json +++ b/test/Resource/Swagger/swagger-x-ms-code-generation-settings.json @@ -1,17 +1,18 @@ -{ - "swagger": "2.0", +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://autorestresourcesproxysite.azurewebsites.net/" + } + ], "info": { "version": "1.0.13", "title": "Swagger Custom Paths", "x-ms-code-generation-settings": { "header": "MIT", "internalConstructors": true - } + } }, - "host": "autorestresourcesproxysite.azurewebsites.net", - "schemes": [ - "http" - ], "paths": { "/values/foo": { "get": { @@ -19,7 +20,6 @@ "Values" ], "operationId": "Values_Get", - "consumes": [ "application/json" ], "responses": { "200": { "description": "OK" @@ -28,4 +28,4 @@ } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-x-ms-discriminator-value.json b/test/Resource/Swagger/swagger-x-ms-discriminator-value.json index 0e634da..da8d7d5 100644 --- a/test/Resource/Swagger/swagger-x-ms-discriminator-value.json +++ b/test/Resource/Swagger/swagger-x-ms-discriminator-value.json @@ -1,5 +1,13 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "http://petstore.swagger.wordnik.com/api" + }, + { + "url": "https://petstore.swagger.wordnik.com/api" + } + ], "info": { "version": "1.0.0", "title": "Swagger Petstore", @@ -15,78 +23,188 @@ "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" } }, - "host": "petstore.swagger.wordnik.com", - "basePath": "/api", - "schemes": [ - "http", "https" - ], - "consumes": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/octet-stream", - "application/zip", - "application/gzip" - ], - "produces": [ - "application/json", - "application/xml", - "application/json; charset=utf-8", - "application/xml; charset=utf-8", - "application/atom+xml", - "application/atom+xml; charset=utf-8", - "application/octet-stream", - "application/zip", - "application/gzip" - ], "paths": { "/pet": { "get": { "description": "Returns all pets from the system that the user has access to", "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], "parameters": [ { "name": "tags", "in": "query", "description": "tags to filter by", "required": false, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "csv" + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } }, { "name": "limit", "in": "query", "description": "maximum number of results to return", "required": false, - "type": "integer", - "format": "int32" + "schema": { + "type": "integer", + "format": "int32" + } } ], "responses": { "200": { "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "text/html": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/json; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/octet-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/zip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/gzip": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } } @@ -94,194 +212,446 @@ "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "pet", - "in": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/newPet" - } - } - ], "responses": { "200": { "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } - } + }, + "requestBody": { + "x-ms-client-name": "pet", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } + }, + "description": "Pet to add to the store", + "required": true + }, + "x-ms-requestBody-index": 0 }, "put": { "tags": [], "summary": "", "description": "", "operationId": "CreateOrUpdatePet", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - ], "responses": { - "200": { "$ref": "#/responses/petResponse" }, + "200": { + "$ref": "#/components/responses/petResponse" + }, "default": { "description": "unexpected error", - "schema": { - "$ref": "#/definitions/errorModel" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } } } }, - "schemes": [ "http", "https" ], "deprecated": true, "security": [], "x-test-header-info": { "name": "x-static-header", "value": "headerValue" - } + }, + "requestBody": { + "x-ms-client-name": "PetCreateOrUpdateParameter", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + }, + "description": "A Pet", + "required": true + }, + "x-ms-requestBody-index": 0 } } }, - "definitions": { - "pet": { - "required": [ - "id", - "name", - "type" - ], - "discriminator": "type", - "x-ms-discriminator-value": "Microsoft.Models.MSPet", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "type": { - "type": "string" + "security": [], + "tags": [], + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name", + "type" + ], + "discriminator": { + "propertyName": "type" }, - "tag": { - "type": "string" + "x-ms-discriminator-value": "Microsoft.Models.MSPet", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "tag": { + "type": "string" + } } - } - }, - "cat": { - "x-ms-discriminator-value": "Microsoft.Models.MSCat", - "allOf": [ { "$ref": "#/definitions/pet" } ], - "required": [ "breed" ], - "properties": { - "breed": { - "type": "string" - }, - "color": { - "type": "string" + }, + "cat": { + "x-ms-discriminator-value": "Microsoft.Models.MSCat", + "allOf": [ + { + "$ref": "#/components/schemas/pet" + } + ], + "required": [ + "breed" + ], + "properties": { + "breed": { + "type": "string" + }, + "color": { + "type": "string" + } } - } - }, - "siamese": { - "x-ms-discriminator-value": "Microsoft.Models.MSSiameseCat", - "allOf": [ { "$ref": "#/definitions/cat" } ], - "properties": { - "mood": { - "type": "string" + }, + "siamese": { + "x-ms-discriminator-value": "Microsoft.Models.MSSiameseCat", + "allOf": [ + { + "$ref": "#/components/schemas/cat" + } + ], + "properties": { + "mood": { + "type": "string" + } } - } - }, - "dog": { - "x-ms-discriminator-value": "Microsoft.Models.MSDog", - "allOf": [ { "$ref": "#/definitions/pet" } ], - "required": [ "pedigree" ], - "properties": { - "pedigree": { - "type": "boolean" + }, + "dog": { + "x-ms-discriminator-value": "Microsoft.Models.MSDog", + "allOf": [ + { + "$ref": "#/components/schemas/pet" + } + ], + "required": [ + "pedigree" + ], + "properties": { + "pedigree": { + "type": "boolean" + } } - } - }, - "newPet": { - "x-ms-discriminator-value": "Microsoft.Models.MSNewPet", - "allOf": [ - { - "$ref": "#/definitions/pet" - }, - { - "required": [ - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" + }, + "newPet": { + "x-ms-discriminator-value": "Microsoft.Models.MSNewPet", + "allOf": [ + { + "$ref": "#/components/schemas/pet" + }, + { + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + } } } + ] + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } } - ] + } }, - "errorModel": { - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "format": "int32" + "responses": { + "petResponse": { + "description": " A created or updated pet", + "headers": { + "x-ms-request-id": { + "description": " The request ID", + "schema": { + "type": "string" + } + } }, - "message": { - "type": "string" - } - } - } - }, - "parameters": { - "petParameter": { - "name": "PetCreateOrUpdateParameter", - "in": "body", - "description": "A Pet", - "required": true, - "schema": { - "$ref": "#/definitions/pet" - } - } - }, - "responses": { - "petResponse": { - "description": " A created or updated pet", - "schema": { - "$ref": "#/definitions/pet" - }, - "headers": { - "x-ms-request-id": { - "description": " The request ID", - "type": "string" + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/json; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/atom+xml; charset=utf-8": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/zip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/gzip": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } } } } - }, - "securityDefinitions": { }, - "security": [ ], - "tags": [ ] -} + } +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-x-ms-parameterized-host.json b/test/Resource/Swagger/swagger-x-ms-parameterized-host.json index 15f18da..dde01ba 100644 --- a/test/Resource/Swagger/swagger-x-ms-parameterized-host.json +++ b/test/Resource/Swagger/swagger-x-ms-parameterized-host.json @@ -1,10 +1,18 @@ -{ - "swagger": "2.0", +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://badhost/" + }, + { + "url": "{accountName}.{host}", + "variables": {} + } + ], "info": { "version": "1.0.13", "title": "Swagger Custom Paths" }, - "host": "badhost", "x-ms-parameterized-host": { "hostTemplate": "{accountName}.{host}", "parameters": [ @@ -13,16 +21,19 @@ "description": "Account Name", "required": false, "type": "string", - "default": "autorestresourcesproxysite" + "default": "autorestresourcesproxysite", + "schema": { + "name": "accountName", + "description": "Account Name", + "type": "string", + "default": "autorestresourcesproxysite" + } }, { - "$ref": "#/parameters/host" + "$ref": "#/components/parameters/host" } ] }, - "schemes": [ - "http" - ], "paths": { "/values/foo": { "get": { @@ -30,7 +41,6 @@ "Values" ], "operationId": "Values_Get", - "consumes": [ "application/json" ], "responses": { "200": { "description": "OK" @@ -39,13 +49,17 @@ } } }, - "parameters": { - "host": { - "name": "host", - "description": "A string value that is used as a global part of the parameterized host", - "type": "string", - "required": false, - "default": "azurewebsites.net" + "components": { + "parameters": { + "host": { + "name": "host", + "description": "A string value that is used as a global part of the parameterized host", + "required": false, + "schema": { + "type": "string", + "default": "azurewebsites.net" + } + } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-x-ms-paths.json b/test/Resource/Swagger/swagger-x-ms-paths.json index 125576e..806c195 100644 --- a/test/Resource/Swagger/swagger-x-ms-paths.json +++ b/test/Resource/Swagger/swagger-x-ms-paths.json @@ -1,13 +1,14 @@ -{ - "swagger": "2.0", +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://autorestresourcesproxysite.azurewebsites.net/" + } + ], "info": { "version": "1.0.13", "title": "Swagger Custom Paths" }, - "host": "autorestresourcesproxysite.azurewebsites.net", - "schemes": [ - "http" - ], "paths": { "/values/foo": { "post": { @@ -15,23 +16,15 @@ "Values" ], "operationId": "Values_Post", - "consumes": [ "application/json" ], - "parameters": [ - { - "name": "body", - "description": "file to upload", - "required": true, - "in": "body", - "schema": { - "$ref": "#/definitions/Product" - } - } - ], "responses": { "200": { "description": "OK" } - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/Product" + }, + "x-ms-requestBody-index": 0 } } }, @@ -42,23 +35,15 @@ "Values" ], "operationId": "Values_CustomPost1", - "consumes": [ "application/json" ], - "parameters": [ - { - "name": "body", - "description": "file to upload", - "required": true, - "in": "body", - "schema": { - "$ref": "#/definitions/Product" - } - } - ], "responses": { "200": { "description": "OK" } - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/Product" + }, + "x-ms-requestBody-index": 0 } }, "/values/foo?query": { @@ -67,33 +52,41 @@ "Values" ], "operationId": "Values_CustomPost2", - "consumes": [ "application/json" ], - "parameters": [ - { - "name": "body", - "description": "file to upload", - "required": true, - "in": "body", - "schema": { - "$ref": "#/definitions/Product" - } - } - ], "responses": { "200": { "description": "OK" } - } + }, + "requestBody": { + "$ref": "#/components/requestBodies/Product" + }, + "x-ms-requestBody-index": 0 } } }, - "definitions": { - "Product": { - "properties": { - "integer": { - "type": "integer" + "components": { + "schemas": { + "Product": { + "properties": { + "integer": { + "type": "integer" + } } } + }, + "requestBodies": { + "Product": { + "x-ms-client-name": "body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Product" + } + } + }, + "description": "file to upload", + "required": true + } } } -} +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-xml-paths.yaml b/test/Resource/Swagger/swagger-xml-paths.yaml index f1a544b..6c906de 100644 --- a/test/Resource/Swagger/swagger-xml-paths.yaml +++ b/test/Resource/Swagger/swagger-xml-paths.yaml @@ -1,32 +1,39 @@ -swagger: "2.0" -info: - title: Xml Tests - version: 1.0.0 -schemes: -- http -consumes: -- application/xml -- application/json -produces: -- application/xml -- application/json -definitions: - ModelComplex: - type: object - properties: - PropertySimple: - description: CUSTOM_PropertySimple # description ~ RealPath (need prefix since "description" is sometimes overridden by something "better" by the modeler) - summary: PropertyOverride # summary ~ RealXmlPath - type: string - xml: - name: PropertyOverride - PropertyArray: - description: CUSTOM_PropertyArray - summary: - type: array - items: - type: string - additionalProperties: - type: string - description: CUSTOM_ - summary: \ No newline at end of file +{ + "openapi": "3.0.0", + "servers": [], + "info": { + "title": "Xml Tests", + "version": "1.0.0" + }, + "paths": {}, + "components": { + "schemas": { + "ModelComplex": { + "type": "object", + "properties": { + "PropertySimple": { + "description": "CUSTOM_PropertySimple", + "summary": "PropertyOverride", + "type": "string", + "xml": { + "name": "PropertyOverride" + } + }, + "PropertyArray": { + "description": "CUSTOM_PropertyArray", + "summary": null, + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": { + "type": "string", + "description": "CUSTOM_", + "summary": null + } + } + } + } +} \ No newline at end of file diff --git a/test/Resource/Swagger/swagger-xml.yaml b/test/Resource/Swagger/swagger-xml.yaml index c57f824..0698af9 100644 --- a/test/Resource/Swagger/swagger-xml.yaml +++ b/test/Resource/Swagger/swagger-xml.yaml @@ -1,51 +1,67 @@ -swagger: "2.0" -info: - title: Xml Tests - version: 1.0.0 -schemes: -- http -consumes: -- application/xml -- application/json -produces: -- application/xml -- application/json -definitions: - ModelPlain: - description: ModelPlain - type: object - properties: - PropertyPlain: - description: PropertyPlain - type: string - PropertyOverridden: - description: PropertyOverride - type: string - xml: - name: PropertyOverride - ModelOverridden: - description: ModelOverride - type: object - xml: - name: ModelOverride - properties: - PropertyPlain: - description: PropertyPlain - type: string - PropertyOverridden: - description: PropertyOverride - type: string - xml: - name: PropertyOverride - ModelComplex: - description: ModelComplex - type: object - properties: - PropertyPlain: - description: PropertyPlain - $ref: "#/definitions/ModelOverridden" - PropertyOverridden: - description: PropertyOverride - $ref: "#/definitions/ModelOverridden" - xml: - name: PropertyOverride \ No newline at end of file +{ + "openapi": "3.0.0", + "servers": [], + "info": { + "title": "Xml Tests", + "version": "1.0.0" + }, + "paths": {}, + "components": { + "schemas": { + "ModelPlain": { + "description": "ModelPlain", + "type": "object", + "properties": { + "PropertyPlain": { + "description": "PropertyPlain", + "type": "string" + }, + "PropertyOverridden": { + "description": "PropertyOverride", + "type": "string", + "xml": { + "name": "PropertyOverride" + } + } + } + }, + "ModelOverridden": { + "description": "ModelOverride", + "type": "object", + "xml": { + "name": "ModelOverride" + }, + "properties": { + "PropertyPlain": { + "description": "PropertyPlain", + "type": "string" + }, + "PropertyOverridden": { + "description": "PropertyOverride", + "type": "string", + "xml": { + "name": "PropertyOverride" + } + } + } + }, + "ModelComplex": { + "description": "ModelComplex", + "type": "object", + "properties": { + "PropertyPlain": { + "description": "PropertyPlain", + "$ref": "#/components/schemas/ModelOverridden" + }, + "PropertyOverridden": { + "description": "PropertyOverride", + "$ref": "#/components/schemas/ModelOverridden", + "xml": { + "name": "PropertyOverride" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Resource/Swagger/vendor-extension-in-path.json b/test/Resource/Swagger/vendor-extension-in-path.json index 94e8a57..709409e 100644 --- a/test/Resource/Swagger/vendor-extension-in-path.json +++ b/test/Resource/Swagger/vendor-extension-in-path.json @@ -1,22 +1,16 @@ { - "swagger": "2.0", + "openapi": "3.0.0", + "servers": [ + { + "url": "https://dsw12.net:999/sandbox/8c88389038102937482abf83f8f/services/5b737fefc19b3047ab4f3234cd34642df2" + } + ], "info": { "version": "2.0", "title": "My web service", "description": "No description provided.", "x-endpoint-name": "default" }, - "host": "dsw12.net:999", - "basePath": "/sandbox/8c88389038102937482abf83f8f/services/5b737fefc19b3047ab4f3234cd34642df2", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], "paths": { "/swagger.json": { "get": { @@ -28,11 +22,13 @@ "in": "query", "description": "API version", "required": false, - "type": "string", - "default": "2.0", - "enum": [ - "2.0" - ] + "schema": { + "type": "string", + "enum": [ + "2.0" + ], + "default": "2.0" + } } ], "responses": { diff --git a/test/SerializationTests.cs b/test/SerializationTests.cs index 0377d9b..e66d01d 100644 --- a/test/SerializationTests.cs +++ b/test/SerializationTests.cs @@ -14,8 +14,8 @@ public void ParseSecurityDefinitionType() var filePath = Path.Combine("Resource", "SerializationTests", "SerializationTests.json"); var swaggerContent = File.ReadAllText(filePath); var definition = SwaggerParser.Parse(swaggerContent); - Assert.Equal(SecuritySchemeType.OAuth2, definition.SecurityDefinitions["petstore_auth"].SecuritySchemeType); - Assert.Equal(SecuritySchemeType.ApiKey, definition.SecurityDefinitions["api_key"].SecuritySchemeType); + Assert.Equal(SecuritySchemeType.OAuth2, definition.Components.SecuritySchemes["petstore_auth"].SecuritySchemeType); + Assert.Equal(SecuritySchemeType.ApiKey, definition.Components.SecuritySchemes["api_key"].SecuritySchemeType); } } } \ No newline at end of file diff --git a/test/SwaggerModelerTests.cs b/test/SwaggerModelerTests.cs index b068294..7d600a4 100644 --- a/test/SwaggerModelerTests.cs +++ b/test/SwaggerModelerTests.cs @@ -67,7 +67,7 @@ public void TestcodeModelFromSimpleSwagger() Assert.True( codeModel.Properties.Any(p => p.Name.EqualsIgnoreCase("apiVersion"))); Assert.Equal("2014-04-01-preview", codeModel.ApiVersion); - Assert.Equal("https://management.azure.com/", codeModel.BaseUrl); + Assert.Equal("https://management.azure.com", codeModel.BaseUrl); Assert.Equal("Some cool documentation.", codeModel.Documentation); //var allMethods = codeModel.Operations.SelectMany(each => each.Methods); Assert.Equal(2, codeModel.Methods.Count); @@ -233,8 +233,7 @@ public void TestcodeModelWithNoContent() Assert.Equal("DeleteBlob", codeModel.Methods[4].Name); Assert.True(codeModel.Methods[4].ReturnType.Body.IsPrimaryType(KnownPrimaryType.Object)); - Assert.True( - codeModel.Methods[4].Responses[HttpStatusCode.OK].Body.IsPrimaryType(KnownPrimaryType.Object)); + Assert.True(codeModel.Methods[4].Responses[HttpStatusCode.OK].Body.IsPrimaryType(KnownPrimaryType.Object)); Assert.Null(codeModel.Methods[4].Responses[HttpStatusCode.BadRequest].Body); } From 639f25381cdbe10faf5eadb278a50f42493ec85e Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Fri, 3 Nov 2017 08:43:47 -0700 Subject: [PATCH 10/13] tweaks --- src/Model/Operation.cs | 23 +++++++++++------------ src/Model/RequestBody.cs | 2 +- src/Model/ServiceDefinition.cs | 7 ------- src/Model/SwaggerParameter.cs | 4 ++-- src/OperationBuilder.cs | 6 +++--- src/SwaggerModeler.cs | 14 ++------------ src/SwaggerParser.cs | 4 ---- 7 files changed, 19 insertions(+), 41 deletions(-) diff --git a/src/Model/Operation.cs b/src/Model/Operation.cs index 790b51b..4694835 100644 --- a/src/Model/Operation.cs +++ b/src/Model/Operation.cs @@ -50,25 +50,24 @@ public string Description public ExternalDoc ExternalDocs { get; set; } // TODO: fix/remove - public IList Consumes + public IEnumerable GetConsumes(Dictionary requestBodies) { - get + var body = RequestBody; + if (body?.Reference != null) { - var result = RequestBody?.Content?.Keys.ToList(); - if (result == null || result.Count == 0) return new List { "application/json" }; - return result; + body = requestBodies[body.Reference.StripComponentsRequestBodyPath()]; } + var result = body?.Content?.Keys.ToList(); + if (result == null || result.Count == 0) return new List { "application/json" }; + return result; } // TODO: fix/remove - public IList Produces + public IEnumerable GetProduces() { - get - { - var result = Responses?.Values.SelectMany(r => r.Content?.Keys ?? Enumerable.Empty()).Distinct().ToList(); - if (result == null || result.Count == 0 || result.Count == 1 && result[0] == "*/*") return new List { "application/json" }; - return result; - } + var result = Responses?.Values.SelectMany(r => r.Content?.Keys ?? Enumerable.Empty()).Distinct().ToList(); + if (result == null || result.Count == 0 || result.Count == 1 && result[0] == "*/*") return new List { "application/json" }; + return result; } [JsonIgnore] diff --git a/src/Model/RequestBody.cs b/src/Model/RequestBody.cs index 078b225..116833c 100644 --- a/src/Model/RequestBody.cs +++ b/src/Model/RequestBody.cs @@ -52,7 +52,7 @@ public IEnumerable AsParameters() { Description = Description, In = ParameterLocation.Body, - Name = Extensions.GetValue("x-ms-client-name") ?? "body", + Name = Extensions.GetValue("x-ms-requestBody-name") ?? "body", IsRequired = Required, Schema = Content?.Values.FirstOrDefault()?.Schema, Reference = Reference, diff --git a/src/Model/ServiceDefinition.cs b/src/Model/ServiceDefinition.cs index 24e60ac..ffc73d6 100644 --- a/src/Model/ServiceDefinition.cs +++ b/src/Model/ServiceDefinition.cs @@ -17,7 +17,6 @@ public class ServiceDefinition : SpecObject public ServiceDefinition() { Components = new Components(); - Schemes = new List(); Paths = new Dictionary>(); CustomPaths = new Dictionary>(); Security = new List>>(); @@ -46,12 +45,6 @@ public ServiceDefinition() /// public IList Schemes { get; set; } - // TODO: remove - public IList Consumes => new List(); - - // TODO: remove - public IList Produces => new List(); - /// /// Key is actual path and the value is serializationProperty of http operations and operation objects. /// diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index 1fbd120..0de6ef2 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -31,14 +31,14 @@ public CollectionFormat CollectionFormat return CollectionFormat.None; // WAT } var style = Style ?? (In == ParameterLocation.Query || In == ParameterLocation.Cookie ? ParameterStyle.Form : ParameterStyle.Simple); - var explode = Explode ?? (style == ParameterStyle.Form); + var explode = Explode ?? (quirksMode ? false : style == ParameterStyle.Form); if (explode) { return CollectionFormat.Multi; } switch (style) { - case ParameterStyle.Simple: + case ParameterStyle.Form: return CollectionFormat.Csv; case ParameterStyle.SpaceDelimited: return CollectionFormat.Ssv; diff --git a/src/OperationBuilder.cs b/src/OperationBuilder.cs index 4fef27c..43aec3e 100644 --- a/src/OperationBuilder.cs +++ b/src/OperationBuilder.cs @@ -37,8 +37,8 @@ public OperationBuilder(Operation operation, SwaggerModeler swaggerModeler) { _operation = operation ?? throw new ArgumentNullException("operation"); _swaggerModeler = swaggerModeler ?? throw new ArgumentNullException("swaggerModeler"); - _effectiveProduces = (operation.Produces.Any() ? operation.Produces : swaggerModeler.ServiceDefinition.Produces).ToList(); - _effectiveConsumes = (operation.Consumes.Any() ? operation.Consumes : swaggerModeler.ServiceDefinition.Consumes).ToList(); + _effectiveProduces = operation.GetProduces().ToList(); + _effectiveConsumes = operation.GetConsumes(swaggerModeler.ServiceDefinition.Components.RequestBodies).ToList(); } public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, string methodGroup) @@ -433,7 +433,7 @@ private bool TryBuildEmptyResponse(string methodName, HttpStatusCode responseSta } else { - if (_operation.Produces.IsNullOrEmpty()) + if (_operation.GetProduces().IsNullOrEmpty()) { method.Responses[responseStatusCode] = new Response(New(KnownPrimaryType.Object), headerType); BuildMethodReturnTypeStack(New(KnownPrimaryType.Object), types); diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index 35fba2e..6be1ff2 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -264,18 +264,8 @@ private void ProcessParameterizedHost() CodeModel.HostParametersBack = hostParamList; } - if (useSchemePrefix) - { - CodeModel.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}", - ServiceDefinition.Schemes[0].ToString().ToLowerInvariant(), - hostTemplate, ServiceDefinition.BasePath); - } - else - { - CodeModel.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}", - hostTemplate, ServiceDefinition.BasePath); - } - + CodeModel.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}", + hostTemplate, ServiceDefinition.BasePath); } } } diff --git a/src/SwaggerParser.cs b/src/SwaggerParser.cs index bc2518c..dee98cb 100644 --- a/src/SwaggerParser.cs +++ b/src/SwaggerParser.cs @@ -44,10 +44,6 @@ public static ServiceDefinition Parse(string swaggerDocument) var swaggerService = JsonConvert.DeserializeObject(swaggerDocument, settings); // for parameterized host, will be made available via JsonRpc accessible state in the future - if (swaggerService.Schemes == null || swaggerService.Schemes.Count != 1) - { - swaggerService.Schemes = new List { TransferProtocolScheme.Http }; - } if (swaggerService.Servers == null || swaggerService.Servers.Count == 0) { swaggerService.Servers = new List From 06542601338f3a93b32feb851735068cca113880 Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Fri, 3 Nov 2017 11:31:10 -0700 Subject: [PATCH 11/13] polish --- src/Model/SwaggerParameter.cs | 4 ++++ src/SwaggerModeler.cs | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Model/SwaggerParameter.cs b/src/Model/SwaggerParameter.cs index 0de6ef2..fb5a8ca 100644 --- a/src/Model/SwaggerParameter.cs +++ b/src/Model/SwaggerParameter.cs @@ -47,6 +47,10 @@ public CollectionFormat CollectionFormat case ParameterStyle.TabDelimited: //FAKE return CollectionFormat.Tsv; } + if (quirksMode) + { + return CollectionFormat.Csv; + } throw new System.NotImplementedException($"Style '{style}' is not yet supported."); } } diff --git a/src/SwaggerModeler.cs b/src/SwaggerModeler.cs index 6be1ff2..51196b8 100644 --- a/src/SwaggerModeler.cs +++ b/src/SwaggerModeler.cs @@ -205,11 +205,6 @@ private void ProcessParameterizedHost() { var hostTemplate = (string)hostExtension["hostTemplate"]; var parametersJson = hostExtension["parameters"].ToString(); - var useSchemePrefix = true; - if (hostExtension.TryGetValue("useSchemePrefix", out var value)) - { - useSchemePrefix = bool.Parse(value.ToString()); - } var position = "first"; From 256c3b87667e5497a5a3e7781eca762b4e8c99bc Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Fri, 3 Nov 2017 13:03:22 -0700 Subject: [PATCH 12/13] cleanup --- .vscode/launch.json | 32 +- src/CollectionFormatBuilder.cs | 2 +- src/Model/Components.cs | 14 +- .../swagger-additional-properties.yaml | 304 +++++++--------- .../Resource/Swagger/swagger-simple-spec.yaml | 340 +++++++----------- test/Resource/Swagger/swagger-xml-paths.yaml | 66 ++-- test/Resource/Swagger/swagger-xml.yaml | 113 +++--- 7 files changed, 345 insertions(+), 526 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0b234c4..6c17d76 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,20 +1,14 @@ { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "attach", - "name": "Attach", - "port": 9229 - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] -} \ No newline at end of file + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] + } \ No newline at end of file diff --git a/src/CollectionFormatBuilder.cs b/src/CollectionFormatBuilder.cs index b152cd8..136adee 100644 --- a/src/CollectionFormatBuilder.cs +++ b/src/CollectionFormatBuilder.cs @@ -28,7 +28,7 @@ public static StringBuilder OnBuildMethodParameter(Method method, if (currentSwaggerParam.Schema?.Type == DataType.Array && !hasCollectionFormat) { // If the parameter type is array default the collectionFormat to csv - currentSwaggerParam.Style = ParameterStyle.Simple; + currentSwaggerParam.Style = ParameterStyle.Form; } if (hasCollectionFormat) diff --git a/src/Model/Components.cs b/src/Model/Components.cs index c433e39..db1ac2b 100644 --- a/src/Model/Components.cs +++ b/src/Model/Components.cs @@ -11,31 +11,19 @@ public Components() { Schemas = new Dictionary(); Parameters = new Dictionary(); + RequestBodies = new Dictionary(); Responses = new Dictionary(); SecuritySchemes = new Dictionary(); } - /// - /// Key is the object serviceTypeName and the value is swagger definition. - /// public Dictionary Schemas { get; set; } - /// - /// Dictionary of parameters that can be used across operations. - /// This property does not define global parameters for all operations. - /// public Dictionary Parameters { get; set; } public Dictionary RequestBodies { get; set; } - /// - /// Dictionary of responses that can be used across operations. The key indicates status code. - /// public Dictionary Responses { get; set; } - /// - /// Key is the object serviceTypeName and the value is swagger security definition. - /// public Dictionary SecuritySchemes { get; set; } } diff --git a/test/Resource/Swagger/swagger-additional-properties.yaml b/test/Resource/Swagger/swagger-additional-properties.yaml index b493250..98f8656 100644 --- a/test/Resource/Swagger/swagger-additional-properties.yaml +++ b/test/Resource/Swagger/swagger-additional-properties.yaml @@ -1,182 +1,122 @@ -{ - "openapi": "3.0.0", - "servers": [ - { - "url": "http://petstore-api.herokuapp.com/pet" - }, - { - "url": "https://petstore-api.herokuapp.com/pet" - } - ], - "info": { - "version": "1.0.0", - "title": "PetStore on Heroku", - "description": "**This example has a working backend hosted in Heroku**\n\nYou can try all HTTP operation described in this Swagger spec.\n\nFind source code of this API [here](https://github.com/mohsen1/petstore-api)\n" - }, - "paths": { - "/": { - "get": { - "operationId": "get_pets", - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "number of pets to return", - "schema": { - "type": "integer", - "minimum": 11, - "maximum": 10000, - "default": 11 - } - } - ], - "responses": { - "200": { - "description": "List all pets", - "content": { - "application/json": { - "schema": { - "title": "Pets", - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "text/html": { - "schema": { - "title": "Pets", - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - } - } - }, - "post": { - "operationId": "post_pets", - "responses": { - "200": { - "description": "Make a new pet" - } - }, - "requestBody": { - "$ref": "#/components/requestBodies/Pet" - }, - "x-ms-requestBody-index": 0 - }, - "put": { - "operationId": "put_pets", - "responses": { - "200": { - "description": "Updates the pet" - } - }, - "requestBody": { - "$ref": "#/components/requestBodies/Pet" - }, - "x-ms-requestBody-index": 0 - } - } - }, - "components": { - "schemas": { - "Pet": { - "type": "object", - "additionalProperties": { - "type": "object", - "$ref": "#/components/schemas/Feature" - }, - "properties": { - "name": { - "type": "string" - }, - "birthday": { - "type": "integer", - "format": "int32" - }, - "wsd": { - "type": "object", - "$ref": "#/components/schemas/WithStringDictionary" - }, - "wud": { - "type": "object", - "$ref": "#/components/schemas/WithUntypedDictionary" - }, - "wtd": { - "type": "object", - "$ref": "#/components/schemas/WithTypedDictionary" - } - } - }, - "Feature": { - "type": "object", - "properties": { - "foo": { - "type": "string" - }, - "bar": { - "type": "integer", - "format": "int32" - } - } - }, - "WithStringDictionary": { - "type": "object", - "properties": { - "abc": { - "type": "string" - } - }, - "additionalProperties": { - "type": "string" - } - }, - "WithUntypedDictionary": { - "properties": { - "abc": { - "type": "string" - } - }, - "type": "object", - "additionalProperties": { - "type": "object" - } - }, - "WithTypedDictionary": { - "type": "object", - "properties": { - "abc": { - "type": "string" - } - }, - "additionalProperties": { - "type": "object", - "$ref": "#/components/schemas/Feature" - } - } - }, - "requestBodies": { - "Pet": { - "x-ms-client-name": "pet", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - }, - "text/xml": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "description": "The pet JSON you want to post", - "required": true - } - } - } -} \ No newline at end of file +openapi: 3.0.0 +servers: +- url: http://petstore-api.herokuapp.com/pet +- url: https://petstore-api.herokuapp.com/pet +info: + version: 1.0.0 + title: PetStore on Heroku + description: | + **This example has a working backend hosted in Heroku** + + You can try all HTTP operation described in this Swagger spec. + + Find source code of this API [here](https://github.com/mohsen1/petstore-api) +paths: + "/": + get: + operationId: get_pets + parameters: + - name: limit + in: query + description: number of pets to return + schema: + type: integer + minimum: 11 + maximum: 10000 + default: 11 + responses: + '200': + description: List all pets + content: + application/json: + schema: + title: Pets + type: array + items: + "$ref": "#/components/schemas/Pet" + text/html: + schema: + title: Pets + type: array + items: + "$ref": "#/components/schemas/Pet" + post: + operationId: post_pets + responses: + '200': + description: Make a new pet + requestBody: + "$ref": "#/components/requestBodies/Pet" + x-ms-requestBody-index: 0 + put: + operationId: put_pets + responses: + '200': + description: Updates the pet + requestBody: + "$ref": "#/components/requestBodies/Pet" + x-ms-requestBody-index: 0 +components: + schemas: + Pet: + type: object + additionalProperties: + type: object + "$ref": "#/components/schemas/Feature" + properties: + name: + type: string + birthday: + type: integer + format: int32 + wsd: + type: object + "$ref": "#/components/schemas/WithStringDictionary" + wud: + type: object + "$ref": "#/components/schemas/WithUntypedDictionary" + wtd: + type: object + "$ref": "#/components/schemas/WithTypedDictionary" + Feature: + type: object + properties: + foo: + type: string + bar: + type: integer + format: int32 + WithStringDictionary: + type: object + properties: + abc: + type: string + additionalProperties: + type: string + WithUntypedDictionary: + properties: + abc: + type: string + type: object + additionalProperties: + type: object + WithTypedDictionary: + type: object + properties: + abc: + type: string + additionalProperties: + type: object + "$ref": "#/components/schemas/Feature" + requestBodies: + Pet: + x-ms-client-name: pet + content: + application/json: + schema: + "$ref": "#/components/schemas/Pet" + text/xml: + schema: + "$ref": "#/components/schemas/Pet" + description: The pet JSON you want to post + required: true diff --git a/test/Resource/Swagger/swagger-simple-spec.yaml b/test/Resource/Swagger/swagger-simple-spec.yaml index 1a34c85..d6d2906 100644 --- a/test/Resource/Swagger/swagger-simple-spec.yaml +++ b/test/Resource/Swagger/swagger-simple-spec.yaml @@ -1,205 +1,135 @@ -{ - "openapi": "3.0.0", - "servers": [ - { - "url": "https://management.azure.com/" - } - ], - "info": { - "title": "Microsoft Azure Redis Cache Management API", - "description": "Some cool documentation.", - "version": "2014-04-01-preview" - }, - "paths": { - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { - "get": { - "operationId": "list", - "summary": "Product Types", - "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", - "parameters": [ - { - "$ref": "#/components/parameters/SubscriptionIdParamterer" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "Resource Group ID.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "$ref": "#/components/parameters/ApiVersionParameter" - } - ], - "tags": [ - "Redis" - ], - "responses": { - "200": { - "description": "A list of caches", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Product" - } - } - } - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - }, - "post": { - "operationId": "reset", - "summary": "Resets products", - "description": "Resets products.", - "parameters": [ - { - "name": "subscriptionId", - "in": "path", - "description": "Subscription ID.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "Resource Group ID.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "apiVersion", - "in": "path", - "description": "API ID.", - "required": true, - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Redis" - ], - "responses": { - "204": { - "description": "A list of caches", - "content": { - "application/json": { - "examples": { - "response": { - "value": { - "id": 9, - "category": { - "name": "domestic" - }, - "name": "monster", - "tags": [ - { - "name": "for sale" - } - ], - "status": "alive" - } - } - } - } - } - }, - "default": { - "description": "Unexpected error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Error" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Product": { - "description": "The product documentation.", - "properties": { - "product_id": { - "type": "string", - "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." - }, - "description": { - "type": "string", - "description": "Description of product." - }, - "display_name": { - "type": "string", - "description": "Display name of product." - }, - "capacity": { - "type": "string", - "description": "Capacity of product. For example, 4 people.", - "default": "100" - }, - "image": { - "type": "string", - "description": "Image URL representing the product." - } - }, - "example": { - "name": "Puma", - "id": 1 - } - }, - "Error": { - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "fields": { - "type": "string" - } - } - } - }, - "parameters": { - "SubscriptionIdParamterer": { - "name": "subscriptionId", - "in": "path", - "description": "Subscription ID.", - "required": true, - "schema": { - "type": "string" - } - }, - "ApiVersionParameter": { - "name": "apiVersion", - "in": "path", - "description": "API ID.", - "required": true, - "schema": { - "type": "string" - } - } - } - } -} \ No newline at end of file +openapi: 3.0.0 +servers: +- url: https://management.azure.com/ +info: + title: Microsoft Azure Redis Cache Management API + description: Some cool documentation. + version: 2014-04-01-preview +paths: + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": + get: + operationId: list + summary: Product Types + description: The Products endpoint returns information about the Uber products + offered at a given location. The response includes the display name and other + details about each product, and lists the products in the proper display order. + parameters: + - "$ref": "#/components/parameters/SubscriptionIdParamterer" + - name: resourceGroupName + in: path + description: Resource Group ID. + required: true + schema: + type: string + - "$ref": "#/components/parameters/ApiVersionParameter" + tags: + - Redis + responses: + '200': + description: A list of caches + content: + application/json: + schema: + "$ref": "#/components/schemas/Product" + default: + description: Unexpected error + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + post: + operationId: reset + summary: Resets products + description: Resets products. + parameters: + - name: subscriptionId + in: path + description: Subscription ID. + required: true + schema: + type: string + - name: resourceGroupName + in: path + description: Resource Group ID. + required: true + schema: + type: string + - name: apiVersion + in: path + description: API ID. + required: true + schema: + type: string + tags: + - Redis + responses: + '204': + description: A list of caches + content: + application/json: + examples: + response: + value: + id: 9 + category: + name: domestic + name: monster + tags: + - name: for sale + status: alive + default: + description: Unexpected error + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" +components: + schemas: + Product: + description: The product documentation. + properties: + product_id: + type: string + description: Unique identifier representing a specific product for a given + latitude & longitude. For example, uberX in San Francisco will have a + different product_id than uberX in Los Angeles. + description: + type: string + description: Description of product. + display_name: + type: string + description: Display name of product. + capacity: + type: string + description: Capacity of product. For example, 4 people. + default: '100' + image: + type: string + description: Image URL representing the product. + example: + name: Puma + id: 1 + Error: + properties: + code: + type: integer + format: int32 + message: + type: string + fields: + type: string + parameters: + SubscriptionIdParamterer: + name: subscriptionId + in: path + description: Subscription ID. + required: true + schema: + type: string + ApiVersionParameter: + name: apiVersion + in: path + description: API ID. + required: true + schema: + type: string diff --git a/test/Resource/Swagger/swagger-xml-paths.yaml b/test/Resource/Swagger/swagger-xml-paths.yaml index 6c906de..44d9b4e 100644 --- a/test/Resource/Swagger/swagger-xml-paths.yaml +++ b/test/Resource/Swagger/swagger-xml-paths.yaml @@ -1,39 +1,27 @@ -{ - "openapi": "3.0.0", - "servers": [], - "info": { - "title": "Xml Tests", - "version": "1.0.0" - }, - "paths": {}, - "components": { - "schemas": { - "ModelComplex": { - "type": "object", - "properties": { - "PropertySimple": { - "description": "CUSTOM_PropertySimple", - "summary": "PropertyOverride", - "type": "string", - "xml": { - "name": "PropertyOverride" - } - }, - "PropertyArray": { - "description": "CUSTOM_PropertyArray", - "summary": null, - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": { - "type": "string", - "description": "CUSTOM_", - "summary": null - } - } - } - } -} \ No newline at end of file +openapi: 3.0.0 +servers: [] +info: + title: Xml Tests + version: 1.0.0 +paths: {} +components: + schemas: + ModelComplex: + type: object + properties: + PropertySimple: + description: CUSTOM_PropertySimple + summary: PropertyOverride + type: string + xml: + name: PropertyOverride + PropertyArray: + description: CUSTOM_PropertyArray + summary: + type: array + items: + type: string + additionalProperties: + type: string + description: CUSTOM_ + summary: diff --git a/test/Resource/Swagger/swagger-xml.yaml b/test/Resource/Swagger/swagger-xml.yaml index 0698af9..d99ec81 100644 --- a/test/Resource/Swagger/swagger-xml.yaml +++ b/test/Resource/Swagger/swagger-xml.yaml @@ -1,67 +1,46 @@ -{ - "openapi": "3.0.0", - "servers": [], - "info": { - "title": "Xml Tests", - "version": "1.0.0" - }, - "paths": {}, - "components": { - "schemas": { - "ModelPlain": { - "description": "ModelPlain", - "type": "object", - "properties": { - "PropertyPlain": { - "description": "PropertyPlain", - "type": "string" - }, - "PropertyOverridden": { - "description": "PropertyOverride", - "type": "string", - "xml": { - "name": "PropertyOverride" - } - } - } - }, - "ModelOverridden": { - "description": "ModelOverride", - "type": "object", - "xml": { - "name": "ModelOverride" - }, - "properties": { - "PropertyPlain": { - "description": "PropertyPlain", - "type": "string" - }, - "PropertyOverridden": { - "description": "PropertyOverride", - "type": "string", - "xml": { - "name": "PropertyOverride" - } - } - } - }, - "ModelComplex": { - "description": "ModelComplex", - "type": "object", - "properties": { - "PropertyPlain": { - "description": "PropertyPlain", - "$ref": "#/components/schemas/ModelOverridden" - }, - "PropertyOverridden": { - "description": "PropertyOverride", - "$ref": "#/components/schemas/ModelOverridden", - "xml": { - "name": "PropertyOverride" - } - } - } - } - } - } -} \ No newline at end of file +openapi: 3.0.0 +servers: [] +info: + title: Xml Tests + version: 1.0.0 +paths: {} +components: + schemas: + ModelPlain: + description: ModelPlain + type: object + properties: + PropertyPlain: + description: PropertyPlain + type: string + PropertyOverridden: + description: PropertyOverride + type: string + xml: + name: PropertyOverride + ModelOverridden: + description: ModelOverride + type: object + xml: + name: ModelOverride + properties: + PropertyPlain: + description: PropertyPlain + type: string + PropertyOverridden: + description: PropertyOverride + type: string + xml: + name: PropertyOverride + ModelComplex: + description: ModelComplex + type: object + properties: + PropertyPlain: + description: PropertyPlain + "$ref": "#/components/schemas/ModelOverridden" + PropertyOverridden: + description: PropertyOverride + "$ref": "#/components/schemas/ModelOverridden" + xml: + name: PropertyOverride From ba58f3febcb226751e8d531e06af16b9df4857fa Mon Sep 17 00:00:00 2001 From: Johannes Bader Date: Fri, 3 Nov 2017 14:22:41 -0700 Subject: [PATCH 13/13] bump --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ea4d1c0..1a81bd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft.azure/autorest.modeler", - "version": "2.1.0", + "version": "2.2.0", "description": "The modeler extension for classic generators in AutoRest.", "scripts": { "start": "dotnet src/bin/netcoreapp2.0/autorest.modeler.dll --server", @@ -46,4 +46,4 @@ "dependencies": { "dotnet-2.0.0": "^1.4.4" } -} +} \ No newline at end of file