-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[General] fix InlineModelResolver's logic and use openapi-generator's InlineModelResolver, so that nested "required" works correctly #1200
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
Changes from all commits
9b10e8f
f669e5a
1ac2ea2
4c822f5
aa31fd6
abac13e
1d6a045
199dea6
7af2cd7
986a1b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -500,6 +500,7 @@ public Schema modelFromProperty(ObjectSchema object, String path) { | |
| model.setExample(example); | ||
| model.setName(object.getName()); | ||
| model.setXml(xml); | ||
| model.setRequired(object.getRequired()); | ||
| if (properties != null) { | ||
| flattenProperties(properties, path); | ||
| model.setProperties(properties); | ||
|
|
@@ -545,6 +546,9 @@ public Schema makeSchema(String ref, Schema property) { | |
|
|
||
| public void copyVendorExtensions(Schema source, Schema target) { | ||
| Map<String, Object> vendorExtensions = source.getExtensions(); | ||
| if (vendorExtensions == null) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sometimes, vendorExtensions is still null... |
||
| return; | ||
| } | ||
| for (String extName : vendorExtensions.keySet()) { | ||
| target.addExtension(extName, vendorExtensions.get(extName)); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -549,7 +549,6 @@ public ClientOptInput toClientOptInput() { | |
| final List<AuthorizationValue> authorizationValues = AuthParser.parse(auth); | ||
| ParseOptions options = new ParseOptions(); | ||
| options.setResolve(true); | ||
| options.setFlatten(true); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this option makes swagger-parser to disassemble inline models into separated models. |
||
| SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options); | ||
|
|
||
| Set<String> validationMessages = new HashSet<>(result.getMessages()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.0.0-SNAPSHOT | ||
| 3.3.2-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Org.OpenAPITools.Model.InlineObject | ||
| ## Properties | ||
|
|
||
| Name | Type | Description | Notes | ||
| ------------ | ------------- | ------------- | ------------- | ||
| **Name** | **string** | Updated name of the pet | [optional] | ||
| **Status** | **string** | Updated status of the pet | [optional] | ||
|
|
||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Org.OpenAPITools.Model.InlineObject1 | ||
| ## Properties | ||
|
|
||
| Name | Type | Description | Notes | ||
| ------------ | ------------- | ------------- | ------------- | ||
| **AdditionalMetadata** | **string** | Additional data to pass to server | [optional] | ||
| **File** | **System.IO.Stream** | file to upload | [optional] | ||
|
|
||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| using System; | ||
| using System.Text; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.Serialization; | ||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Org.OpenAPITools.Model { | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| [DataContract] | ||
| public class InlineObject { | ||
| /// <summary> | ||
| /// Updated name of the pet | ||
| /// </summary> | ||
| /// <value>Updated name of the pet</value> | ||
| [DataMember(Name="name", EmitDefaultValue=false)] | ||
| [JsonProperty(PropertyName = "name")] | ||
| public string Name { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Updated status of the pet | ||
| /// </summary> | ||
| /// <value>Updated status of the pet</value> | ||
| [DataMember(Name="status", EmitDefaultValue=false)] | ||
| [JsonProperty(PropertyName = "status")] | ||
| public string Status { get; set; } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Get the string presentation of the object | ||
| /// </summary> | ||
| /// <returns>String presentation of the object</returns> | ||
| public override string ToString() { | ||
| var sb = new StringBuilder(); | ||
| sb.Append("class InlineObject {\n"); | ||
| sb.Append(" Name: ").Append(Name).Append("\n"); | ||
| sb.Append(" Status: ").Append(Status).Append("\n"); | ||
| sb.Append("}\n"); | ||
| return sb.ToString(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get the JSON string presentation of the object | ||
| /// </summary> | ||
| /// <returns>JSON string presentation of the object</returns> | ||
| public string ToJson() { | ||
| return JsonConvert.SerializeObject(this, Formatting.Indented); | ||
| } | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| using System; | ||
| using System.Text; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.Serialization; | ||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Org.OpenAPITools.Model { | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| [DataContract] | ||
| public class InlineObject1 { | ||
| /// <summary> | ||
| /// Additional data to pass to server | ||
| /// </summary> | ||
| /// <value>Additional data to pass to server</value> | ||
| [DataMember(Name="additionalMetadata", EmitDefaultValue=false)] | ||
| [JsonProperty(PropertyName = "additionalMetadata")] | ||
| public string AdditionalMetadata { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// file to upload | ||
| /// </summary> | ||
| /// <value>file to upload</value> | ||
| [DataMember(Name="file", EmitDefaultValue=false)] | ||
| [JsonProperty(PropertyName = "file")] | ||
| public System.IO.Stream File { get; set; } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Get the string presentation of the object | ||
| /// </summary> | ||
| /// <returns>String presentation of the object</returns> | ||
| public override string ToString() { | ||
| var sb = new StringBuilder(); | ||
| sb.Append("class InlineObject1 {\n"); | ||
| sb.Append(" AdditionalMetadata: ").Append(AdditionalMetadata).Append("\n"); | ||
| sb.Append(" File: ").Append(File).Append("\n"); | ||
| sb.Append("}\n"); | ||
| return sb.ToString(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get the JSON string presentation of the object | ||
| /// </summary> | ||
| /// <returns>JSON string presentation of the object</returns> | ||
| public string ToJson() { | ||
| return JsonConvert.SerializeObject(this, Formatting.Indented); | ||
| } | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="RestSharp.Net2" version="1.1.11" targetFramework="net20" developmentDependency="true" /> | ||
| <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net20" developmentDependency="true" /> | ||
| </packages> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.3.0-SNAPSHOT | ||
| 3.3.2-SNAPSHOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget copy "required" to the separated object