Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup #32

Merged
merged 8 commits into from
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/CollectionFormatBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace AutoRest.Modeler
{
public static class CollectionFormatBuilder
{
public static StringBuilder OnBuildMethodParameter(Method method,
public static void OnBuildMethodParameter(Method method,
SwaggerParameter currentSwaggerParam,
StringBuilder paramNameBuilder)
string paramNameBuilder)
{
if (currentSwaggerParam == null)
{
Expand All @@ -31,21 +31,15 @@ public static StringBuilder OnBuildMethodParameter(Method method,
currentSwaggerParam.Style = ParameterStyle.Form;
}

if (hasCollectionFormat)
if (hasCollectionFormat && currentSwaggerParam.In == ParameterLocation.Path)
{
if (currentSwaggerParam.In == ParameterLocation.Path)
if (method?.Url == null)
{
if (method == null || method.Url == null)
{
throw new ArgumentNullException("method");
}

method.Url = ((string)method.Url).Replace(
string.Format(CultureInfo.InvariantCulture, "{0}", currentSwaggerParam.Name),
string.Format(CultureInfo.InvariantCulture, "{0}", paramNameBuilder));
throw new ArgumentNullException("method");
}

method.Url = method.Url.Replace(currentSwaggerParam.Name, paramNameBuilder);
}
return paramNameBuilder;
}
}
}
30 changes: 0 additions & 30 deletions src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@
Target = "AutoRest.Modeler.SwaggerModeler.#BuildMethod(AutoRest.Core.Model.HttpMethod,System.String,System.String,AutoRest.Modeler.Model.Operation)", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings",
Scope = "member", Target = "AutoRest.Modeler.SwaggerModeler.#BuildMethodBaseUrl(AutoRest.Core.Model.CodeModel,System.String)", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",
Scope = "member", Target = "AutoRest.Modeler.Model.Contact.#Url", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",
Scope = "member", Target = "AutoRest.Modeler.Model.ExternalDoc.#Url", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",
Scope = "member", Target = "AutoRest.Modeler.Model.License.#Url", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",
Scope = "member", Target = "AutoRest.Modeler.Model.SecurityDefinition.#AuthorizationUrl", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",
Scope = "member", Target = "AutoRest.Modeler.Model.SecurityDefinition.#TokenUrl", Justification = "May not parse as valid Uri")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "AutoRest.Core.Logging.ErrorManager.CreateError(System.String,System.Object[])", Scope = "member", Target = "AutoRest.Modeler.SwaggerParser.#Parse(System.String)", Justification = "Generated Code")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase",
Scope = "member", Target = "AutoRest.Modeler.Extensions.#ToHttpMethod(System.String)", Justification = "Serialization Type")]
Expand All @@ -50,16 +44,8 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
MessageId = "Param", Scope = "member",
Target = "AutoRest.Modeler.CollectionFormatBuilder.#OnBuildMethodParameter(AutoRest.Core.Model.Method,AutoRest.Modeler.Model.SwaggerParameter,System.Text.StringBuilder)", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly",
MessageId = "OAuth", Scope = "type", Target = "AutoRest.Modeler.Model.OAuthFlow", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly",
MessageId = "OAuth", Scope = "member", Target = "AutoRest.Modeler.Model.SecuritySchemeType.#OAuth2", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
MessageId = "Ws", Scope = "member", Target = "AutoRest.Modeler.Model.TransferProtocolScheme.#Ws", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
MessageId = "Wss", Scope = "member", Target = "AutoRest.Modeler.Model.TransferProtocolScheme.#Wss", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly",
MessageId = "Ws", Scope = "member", Target = "AutoRest.Modeler.Model.TransferProtocolScheme.#Ws", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords",
MessageId = "Default", Scope = "member", Target = "AutoRest.Modeler.Model.SwaggerObject.#Default", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords",
Expand All @@ -85,8 +71,6 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming",
"CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "multi", Scope = "resource",
Target = "AutoRest.Modeler.Properties.Resources.resources", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
MessageId = "Auth", Scope = "type", Target = "AutoRest.Modeler.Model.OAuthFlow", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
MessageId = "Auth", Scope = "member", Target = "AutoRest.Modeler.Model.SecuritySchemeType.#OAuth2")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Expand All @@ -113,22 +97,8 @@
Scope = "member", Target = "AutoRest.Modeler.Model.Schema.#Required", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.Schema.#AllOf", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.SecurityDefinition.#Scopes", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Schemes", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Consumes", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Produces", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Paths", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Definitions", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Parameters", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#Responses", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Scope = "member", Target = "AutoRest.Modeler.Model.ServiceDefinition.#SecurityDefinitions", Justification = "Serialization Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly",
Expand Down
5 changes: 1 addition & 4 deletions src/JsonConverters/PathItemRefConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ public PathItemRefConverter(string json)
}

public override bool CanConvert(System.Type objectType)
{
// Type of a path item object
return objectType == typeof (Dictionary<string, Operation>);
}
=> objectType == typeof (Dictionary<string, Operation>);

public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue,
JsonSerializer serializer)
Expand Down
4 changes: 1 addition & 3 deletions src/JsonConverters/PathLevelParameterConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public PathLevelParameterConverter(string json)
}

public override bool CanConvert(System.Type objectType)
{
return (objectType == typeof (Dictionary<string, Operation>));
}
=> objectType == typeof (Dictionary<string, Operation>);

/// <summary>
/// To merge common parameters at the path level into the parameters at
Expand Down
41 changes: 0 additions & 41 deletions src/JsonConverters/SecurityDefinitionConverter.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Model/ApiKeyLocation.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Model/CodeGenerationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace AutoRest.Modeler.Model
/// The metadata can be used by the clients if needed, and can be presented
/// in the Swagger-UI for convenience.
/// </summary>
public class CodeGenerationSettings : SpecObject
public class CodeGenerationSettings : SwaggerBase
{
}
}
3 changes: 0 additions & 3 deletions src/Model/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public Components()
Parameters = new Dictionary<string, SwaggerParameter>();
RequestBodies = new Dictionary<string, RequestBody>();
Responses = new Dictionary<string, OperationResponse>();
SecuritySchemes = new Dictionary<string, SecurityDefinition>();
}

public Dictionary<string, Schema> Schemas { get; set; }
Expand All @@ -24,7 +23,5 @@ public Components()

public Dictionary<string, OperationResponse> Responses { get; set; }

public Dictionary<string, SecurityDefinition> SecuritySchemes { get; set; }

}
}
28 changes: 0 additions & 28 deletions src/Model/Contact.cs

This file was deleted.

8 changes: 1 addition & 7 deletions src/Model/ExternalDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ namespace AutoRest.Modeler.Model
/// </summary>
public class ExternalDoc
{
private string _description;

/// <summary>
/// Url of external Swagger doc.
/// </summary>
Expand All @@ -20,10 +18,6 @@ public class ExternalDoc
/// <summary>
/// Description of external Swagger doc.
/// </summary>
public string Description
{
get { return _description; }
set { _description = value.StripControlCharacters(); ; }
}
public string Description { get; set; }
}
}
8 changes: 1 addition & 7 deletions src/Model/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace AutoRest.Modeler.Model
/// The metadata can be used by the clients if needed, and can be presented
/// in the Swagger-UI for convenience.
/// </summary>
public class Info : SpecObject
public class Info : SwaggerBase
{
private string _description;
public string Title { get; set; }
Expand All @@ -28,12 +28,6 @@ public string Description
}
}

public string TermsOfService { get; set; }

public Contact Contact { get; set; }

public License License { get; set; }

public string Version { get; set; }

[JsonProperty("x-ms-code-generation-settings")]
Expand Down
23 changes: 0 additions & 23 deletions src/Model/License.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Model/OAuthFlow.cs

This file was deleted.

Loading