Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 55ef00b

Browse files
authored
v2 changes Java CodegenX.ref type from String to CodegenX (#117)
* petstore regen * Sets response ref to CodegenResponse instance * Endpoint test fix, petstore regen * Updates codegenHeader * codegenRequestBody ref update in java * Fixes endpoint + endpoint docs fro request body, example still broken * Fixes request body examples * Fixes requiredVars * Adds response_for_200 info back into endpoint docs * Adds response_for_200 back into response header anchor links * Fixes header component links in scomponent response * Updates codegenParameter * Templates updated to get ref parameters working * Uses setLocationInfo in fromSchema * Uses a constant and already calculated adProp for required props, reduces fromSchema calls * Uses codegenSchemaCache.computeIfAbsent in fromSchema * Removes unaliasing from fromSchema * Petstore regen * Adds JsonIgnore to fix debugging * Sample regen * Samples regenerated * Points refs to component schemas, fixes java test * Fixes java test * Fixes testAlias * Fixes 2 java tests * Fixes testUnalias * Fixes testNullableProperty * Fixes testDeprecatedRef * Fixes testRequestBodyContent * Fixes testAdditionalPropertiesPresentInResponses * Fixes testAdditionalPropertiesPresentInParameters * Fixes testIsXPresence * Fixes testResponseContentAndHeader * Fixes DefaultGeneratorTests * Fixes AbstractJavaCodegenExampleValuesTest * Samples updated
1 parent 93bae60 commit 55ef00b

File tree

115 files changed

+1773
-1469
lines changed
  • modules/openapi-json-schema-generator/src
  • samples/openapi3/client
    • 3_0_3_unit_test/python/test/test_paths
      • test_response_body_post_additionalproperties_allows_a_schema_which_should_validate_response_body_for_content_types
      • test_response_body_post_additionalproperties_are_allowed_by_default_response_body_for_content_types
      • test_response_body_post_additionalproperties_can_exist_by_itself_response_body_for_content_types
      • test_response_body_post_additionalproperties_should_not_look_in_applicators_response_body_for_content_types
      • test_response_body_post_allof_combined_with_anyof_oneof_response_body_for_content_types
      • test_response_body_post_allof_response_body_for_content_types
      • test_response_body_post_allof_simple_types_response_body_for_content_types
      • test_response_body_post_allof_with_base_schema_response_body_for_content_types
      • test_response_body_post_allof_with_one_empty_schema_response_body_for_content_types
      • test_response_body_post_allof_with_the_first_empty_schema_response_body_for_content_types
      • test_response_body_post_allof_with_the_last_empty_schema_response_body_for_content_types
      • test_response_body_post_allof_with_two_empty_schemas_response_body_for_content_types
      • test_response_body_post_anyof_complex_types_response_body_for_content_types
      • test_response_body_post_anyof_response_body_for_content_types
      • test_response_body_post_anyof_with_base_schema_response_body_for_content_types
      • test_response_body_post_anyof_with_one_empty_schema_response_body_for_content_types
      • test_response_body_post_array_type_matches_arrays_response_body_for_content_types
      • test_response_body_post_boolean_type_matches_booleans_response_body_for_content_types
      • test_response_body_post_by_int_response_body_for_content_types
      • test_response_body_post_by_number_response_body_for_content_types
      • test_response_body_post_by_small_number_response_body_for_content_types
      • test_response_body_post_date_time_format_response_body_for_content_types
      • test_response_body_post_email_format_response_body_for_content_types
      • test_response_body_post_enum_with0_does_not_match_false_response_body_for_content_types
      • test_response_body_post_enum_with1_does_not_match_true_response_body_for_content_types
      • test_response_body_post_enum_with_escaped_characters_response_body_for_content_types
      • test_response_body_post_enum_with_false_does_not_match0_response_body_for_content_types
      • test_response_body_post_enum_with_true_does_not_match1_response_body_for_content_types
      • test_response_body_post_enums_in_properties_response_body_for_content_types
      • test_response_body_post_forbidden_property_response_body_for_content_types
      • test_response_body_post_hostname_format_response_body_for_content_types
      • test_response_body_post_integer_type_matches_integers_response_body_for_content_types
      • test_response_body_post_invalid_instance_should_not_raise_error_when_float_division_inf_response_body_for_content_types
      • test_response_body_post_invalid_string_value_for_default_response_body_for_content_types
      • test_response_body_post_ipv4_format_response_body_for_content_types
      • test_response_body_post_ipv6_format_response_body_for_content_types
      • test_response_body_post_json_pointer_format_response_body_for_content_types
      • test_response_body_post_maximum_validation_response_body_for_content_types
      • test_response_body_post_maximum_validation_with_unsigned_integer_response_body_for_content_types
      • test_response_body_post_maxitems_validation_response_body_for_content_types
      • test_response_body_post_maxlength_validation_response_body_for_content_types
      • test_response_body_post_maxproperties0_means_the_object_is_empty_response_body_for_content_types
      • test_response_body_post_maxproperties_validation_response_body_for_content_types
      • test_response_body_post_minimum_validation_response_body_for_content_types
      • test_response_body_post_minimum_validation_with_signed_integer_response_body_for_content_types
      • test_response_body_post_minitems_validation_response_body_for_content_types
      • test_response_body_post_minlength_validation_response_body_for_content_types
      • test_response_body_post_minproperties_validation_response_body_for_content_types
      • test_response_body_post_nested_allof_to_check_validation_semantics_response_body_for_content_types
      • test_response_body_post_nested_anyof_to_check_validation_semantics_response_body_for_content_types
      • test_response_body_post_nested_items_response_body_for_content_types
      • test_response_body_post_nested_oneof_to_check_validation_semantics_response_body_for_content_types
      • test_response_body_post_not_more_complex_schema_response_body_for_content_types
      • test_response_body_post_not_response_body_for_content_types
      • test_response_body_post_nul_characters_in_strings_response_body_for_content_types
      • test_response_body_post_null_type_matches_only_the_null_object_response_body_for_content_types
      • test_response_body_post_number_type_matches_numbers_response_body_for_content_types
      • test_response_body_post_object_properties_validation_response_body_for_content_types
      • test_response_body_post_object_type_matches_objects_response_body_for_content_types
      • test_response_body_post_oneof_complex_types_response_body_for_content_types
      • test_response_body_post_oneof_response_body_for_content_types
      • test_response_body_post_oneof_with_base_schema_response_body_for_content_types
      • test_response_body_post_oneof_with_empty_schema_response_body_for_content_types
      • test_response_body_post_oneof_with_required_response_body_for_content_types
      • test_response_body_post_pattern_is_not_anchored_response_body_for_content_types
      • test_response_body_post_pattern_validation_response_body_for_content_types
      • test_response_body_post_properties_with_escaped_characters_response_body_for_content_types
      • test_response_body_post_property_named_ref_that_is_not_a_reference_response_body_for_content_types
      • test_response_body_post_ref_in_additionalproperties_response_body_for_content_types
      • test_response_body_post_ref_in_allof_response_body_for_content_types
      • test_response_body_post_ref_in_anyof_response_body_for_content_types
      • test_response_body_post_ref_in_items_response_body_for_content_types
      • test_response_body_post_ref_in_not_response_body_for_content_types
      • test_response_body_post_ref_in_oneof_response_body_for_content_types
      • test_response_body_post_ref_in_property_response_body_for_content_types
      • test_response_body_post_required_default_validation_response_body_for_content_types
      • test_response_body_post_required_validation_response_body_for_content_types
      • test_response_body_post_required_with_empty_array_response_body_for_content_types
      • test_response_body_post_required_with_escaped_characters_response_body_for_content_types
      • test_response_body_post_simple_enum_validation_response_body_for_content_types
      • test_response_body_post_string_type_matches_strings_response_body_for_content_types
      • test_response_body_post_the_default_keyword_does_not_do_anything_if_the_property_is_missing_response_body_for_content_types
      • test_response_body_post_uniqueitems_false_validation_response_body_for_content_types
      • test_response_body_post_uniqueitems_validation_response_body_for_content_types
      • test_response_body_post_uri_format_response_body_for_content_types
      • test_response_body_post_uri_reference_format_response_body_for_content_types
      • test_response_body_post_uri_template_format_response_body_for_content_types
    • petstore/python/docs/apis/tags/user_api

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1773
-1469
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeader.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public String toString() {
9393
return sb.toString();
9494
}
9595

96+
@Override
97+
public CodegenHeader getRef() { return (CodegenHeader) ref; }
98+
9699
public CodegenSchema getSchema() {
97100
return schema;
98101
}

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
package org.openapitools.codegen;
1919

2020
import io.swagger.v3.oas.models.ExternalDocumentation;
21+
import com.fasterxml.jackson.annotation.JsonIgnore;
2122

2223
import java.util.*;
23-
import java.util.stream.Collectors;
2424

2525
public class CodegenOperation {
2626
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams,
@@ -169,12 +169,19 @@ public boolean getAllResponsesAreErrors() {
169169
* returns a map where the key is the request body content type and the value is the current CodegenOperation
170170
* this is needed by templates when a different signature is needed for each request body content type
171171
*/
172+
@JsonIgnore
172173
public Map<String, CodegenOperation> getContentTypeToOperation() {
173174
LinkedHashMap<String, CodegenOperation> contentTypeToOperation = new LinkedHashMap<>();
174175
if (requestBody == null) {
175176
return null;
176177
}
177-
LinkedHashMap<String, CodegenMediaType> content = requestBody.getContent();
178+
LinkedHashMap<String, CodegenMediaType> content;
179+
CodegenRequestBody ref = (CodegenRequestBody) requestBody.getRef();
180+
if (ref != null) {
181+
content = ref.getContent();
182+
} else {
183+
content = requestBody.getContent();
184+
}
178185
for (String contentType: content.keySet()) {
179186
contentTypeToOperation.put(contentType, this);
180187
}

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class CodegenParameter extends CodegenHeader {
3030
// stores the openapi name property
3131
public String baseName;
3232

33+
public CodegenParameter getRef() { return (CodegenParameter) ref; }
34+
3335
@Override
3436
public int hashCode() {
3537
return Objects.hash(refClass, name, isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isExplode, baseName, description, unescapedDescription, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, ref, refModule, imports, componentModule);

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBody.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CodegenRequestBody implements OpenApiComponent {
2626
*/
2727
protected boolean required;
2828
protected LinkedHashMap<String, CodegenMediaType> content;
29-
protected String ref;
29+
protected Object ref;
3030
protected String refModule;
3131
protected Set<String> imports = new HashSet<String>();
3232
protected String componentModule;
@@ -109,9 +109,9 @@ public void setContent(LinkedHashMap<String, CodegenMediaType> content) {
109109

110110
public void setName(CodegenKey name) { this.name=name; }
111111

112-
public String getRef() { return ref; }
112+
public CodegenRequestBody getRef() { return (CodegenRequestBody) ref; }
113113

114-
public void setRef(String ref) { this.ref=ref; }
114+
public void setRef(Object ref) { this.ref = ref; }
115115

116116
public String getRefModule() { return refModule; }
117117

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class CodegenResponse implements OpenApiComponent {
2727
public String jsonSchema;
2828
public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
2929
private LinkedHashMap<String, CodegenMediaType> content;
30-
private String ref;
30+
private CodegenResponse ref;
3131
public Set<String> imports = new TreeSet<>();
3232
private String refModule;
3333
private String refClass;
@@ -103,9 +103,9 @@ public String toString() {
103103
return sb.toString();
104104
}
105105

106-
public String getRef() { return ref; }
106+
public CodegenResponse getRef() { return ref; }
107107

108-
public void setRef(String ref) { this.ref=ref; }
108+
public void setRef(Object ref) { this.ref = (CodegenResponse) ref; }
109109

110110
public String getRefModule() { return refModule; }
111111

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenSchema.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
package org.openapitools.codegen;
1919

2020
import io.swagger.v3.oas.models.ExternalDocumentation;
21+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2122

2223
import java.util.*;
2324

25+
@JsonIgnoreProperties({"ref"})
2426
public class CodegenSchema implements OpenApiSchema, OpenApiComponent {
2527
// testCases are for autogenerated tests of schemas
2628
public HashMap<String, SchemaTestCase> testCases = new HashMap<>();
@@ -155,7 +157,7 @@ public class CodegenSchema implements OpenApiSchema, OpenApiComponent {
155157
private LinkedHashMap<CodegenKey, CodegenSchema> requiredProperties;
156158
private LinkedHashMap<CodegenKey, CodegenSchema> properties;
157159
private LinkedHashMap<CodegenKey, CodegenSchema> optionalProperties;
158-
private String ref;
160+
private CodegenSchema ref;
159161
private String refModule;
160162
private boolean schemaIsFromAdditionalProperties;
161163
private boolean isBooleanSchemaTrue;
@@ -584,12 +586,12 @@ public CodegenSchema getNot() {
584586
}
585587

586588
@Override
587-
public void setRef(String ref) {
588-
this.ref = ref;
589+
public void setRef(Object ref) {
590+
this.ref = (CodegenSchema) ref;
589591
}
590592

591593
@Override
592-
public String getRef() {
594+
public CodegenSchema getRef() {
593595
return ref;
594596
}
595597

@@ -942,7 +944,7 @@ public int hashCode() {
942944
maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
943945
xmlNamespace, isXmlWrapped, isNull,
944946
hasDiscriminatorWithNonEmptyMapping, hasMultipleTypes,
945-
ref, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse,
947+
schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse,
946948
format, dependentRequired, contains, refModule, allOf, anyOf, oneOf, not,
947949
properties, optionalProperties, requiredProperties, externalDocumentation,
948950
discriminator, imports, componentModule, testCases);

0 commit comments

Comments
 (0)