forked from loafle/openapi-generator-original
Better inline schema naming for double byte characters (#16035)
* better inline schema naming for double byte characters * clean up * update deprecated methods
This commit is contained in:
@@ -31,12 +31,10 @@ import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InlineModelResolver {
|
||||
private OpenAPI openAPI;
|
||||
@@ -679,7 +677,7 @@ public class InlineModelResolver {
|
||||
* @return if provided the sanitized {@code title}, else the sanitized {@code key}
|
||||
*/
|
||||
private String resolveModelName(String title, String modelName) {
|
||||
if (title == null) {
|
||||
if (title == null || "".equals(sanitizeName(title).replace("_", ""))) {
|
||||
if (modelName == null) {
|
||||
return uniqueName("inline_object");
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ public class PhpDataTransferClientCodegen extends AbstractPhpCodegen {
|
||||
//Generate special component schema for container
|
||||
String containerSchemaName = generateUniqueSchemaName(openAPI, "Collection");
|
||||
Schema containerSchema = new ObjectSchema();
|
||||
containerSchema.addProperties("inner", schema);
|
||||
containerSchema.addProperty("inner", schema);
|
||||
addInternalExtensionToSchema(containerSchema, VEN_FROM_CONTAINER, Boolean.TRUE);
|
||||
openAPI.getComponents().addSchemas(containerSchemaName, containerSchema);
|
||||
String containerDataType = getTypeDeclaration(toModelName(containerSchemaName));
|
||||
|
||||
@@ -412,7 +412,7 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
|
||||
//Generate special component schema for container
|
||||
String containerSchemaName = generateUniqueSchemaName(openAPI, "Collection");
|
||||
Schema containerSchema = new ObjectSchema();
|
||||
containerSchema.addProperties("inner", schema);
|
||||
containerSchema.addProperty("inner", schema);
|
||||
addInternalExtensionToSchema(containerSchema, VEN_FROM_CONTAINER, Boolean.TRUE);
|
||||
openAPI.getComponents().addSchemas(containerSchemaName, containerSchema);
|
||||
String containerDataType = getTypeDeclaration(toModelName(containerSchemaName));
|
||||
|
||||
@@ -46,14 +46,14 @@ public class InlineModelResolverTest {
|
||||
openapi.getComponents().addSchemas("User", new ObjectSchema()
|
||||
.name("user")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.description("description")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())));
|
||||
|
||||
assertNotNull((openapi.getComponents().getSchemas().get("User")).getProperties().get("address"));
|
||||
|
||||
@@ -79,14 +79,14 @@ public class InlineModelResolverTest {
|
||||
openapi.getComponents().addSchemas("User", new ObjectSchema()
|
||||
.name("user")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.title("UserAddressTitle")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())));
|
||||
|
||||
new InlineModelResolver().flatten(openapi);
|
||||
|
||||
@@ -108,14 +108,14 @@ public class InlineModelResolverTest {
|
||||
openapi.getComponents().addSchemas("User", new ObjectSchema()
|
||||
.name("user")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.title("User Address Title")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())));
|
||||
|
||||
new InlineModelResolver().flatten(openapi);
|
||||
|
||||
@@ -137,27 +137,27 @@ public class InlineModelResolverTest {
|
||||
openapi.getComponents().addSchemas("User", new ObjectSchema()
|
||||
.name("user")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.title("UserAddressTitle")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())));
|
||||
|
||||
openapi.getComponents().addSchemas("AnotherUser", new ObjectSchema()
|
||||
.name("user")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("lastName", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("lastName", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.title("UserAddressTitle")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())));
|
||||
|
||||
new InlineModelResolver().flatten(openapi);
|
||||
|
||||
@@ -181,28 +181,28 @@ public class InlineModelResolverTest {
|
||||
openapi.getComponents().addSchemas("User", new ObjectSchema()
|
||||
.name("user")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.title("UserAddressTitle")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())));
|
||||
|
||||
openapi.getComponents().addSchemas("AnotherUser", new ObjectSchema()
|
||||
.name("AnotherUser")
|
||||
.description("a common user")
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("lastName", new StringSchema())
|
||||
.addProperties("address", new ObjectSchema()
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("lastName", new StringSchema())
|
||||
.addProperty("address", new ObjectSchema()
|
||||
.title("UserAddressTitle")
|
||||
.readOnly(false)
|
||||
.description("description")
|
||||
.name("name")
|
||||
.addProperties("street", new StringSchema())
|
||||
.addProperties("city", new StringSchema())
|
||||
.addProperties("apartment", new StringSchema())));
|
||||
.addProperty("street", new StringSchema())
|
||||
.addProperty("city", new StringSchema())
|
||||
.addProperty("apartment", new StringSchema())));
|
||||
|
||||
new InlineModelResolver().flatten(openapi);
|
||||
|
||||
@@ -238,14 +238,14 @@ public class InlineModelResolverTest {
|
||||
.description("it works!")
|
||||
.content(new Content().addMediaType("application/json",
|
||||
new MediaType().schema(new ObjectSchema().title("inline_response_200")
|
||||
.addProperties("name", new StringSchema()).extensions(propExt))))))))
|
||||
.addProperty("name", new StringSchema()).extensions(propExt))))))))
|
||||
.path("/foo/baz", new PathItem()
|
||||
.get(new Operation().responses(new ApiResponses().addApiResponse("200", new ApiResponse()
|
||||
.description("it works!")
|
||||
.extensions(responseExt)
|
||||
.content(new Content().addMediaType("application/json",
|
||||
new MediaType().schema(new ObjectSchema()
|
||||
.addProperties("name", new StringSchema()).extensions(propExt))))))));
|
||||
.addProperty("name", new StringSchema()).extensions(propExt))))))));
|
||||
|
||||
new InlineModelResolver().flatten(openapi);
|
||||
|
||||
@@ -297,14 +297,14 @@ public class InlineModelResolverTest {
|
||||
.description("it works!")
|
||||
.content(new Content().addMediaType("application/json",
|
||||
new MediaType().schema(new ObjectSchema().title("GetBarResponse")
|
||||
.addProperties("name", new StringSchema()).extensions(propExt))))))))
|
||||
.addProperty("name", new StringSchema()).extensions(propExt))))))))
|
||||
.path("/foo/baz", new PathItem()
|
||||
.get(new Operation().responses(new ApiResponses().addApiResponse("200", new ApiResponse()
|
||||
.description("it works!")
|
||||
.extensions(responseExt)
|
||||
.content(new Content().addMediaType("application/json",
|
||||
new MediaType().schema(new ObjectSchema()
|
||||
.addProperties("name", new StringSchema()).extensions(propExt))))))));
|
||||
.addProperty("name", new StringSchema()).extensions(propExt))))))));
|
||||
|
||||
new InlineModelResolver().flatten(openapi);
|
||||
|
||||
@@ -411,6 +411,16 @@ public class InlineModelResolverTest {
|
||||
requestBodyReference.getContent().get("application/json").getSchema().get$ref());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveInlineRequestBodyWithTitleInChinese() {
|
||||
OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0/inline_model_resolver.yaml");
|
||||
new InlineModelResolver().flatten(openAPI);
|
||||
|
||||
RequestBody requestBodyReference = openAPI.getPaths().get("/resolve_inline_request_body_with_title_in_chinese").getPost().getRequestBody();
|
||||
assertEquals("#/components/schemas/resolveInlineRequestBodyWithRequired_request_1",
|
||||
requestBodyReference.getContent().get("application/json").getSchema().get$ref());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonModelRequestBody() {
|
||||
OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0/inline_model_resolver.yaml");
|
||||
@@ -553,9 +563,9 @@ public class InlineModelResolverTest {
|
||||
"application/json",
|
||||
new MediaType().schema(
|
||||
new MapSchema().additionalProperties(
|
||||
new ObjectSchema().addProperties(
|
||||
new ObjectSchema().addProperty(
|
||||
"resolve_inline_map_schema_in_response_property",
|
||||
new ObjectSchema().addProperties(
|
||||
new ObjectSchema().addProperty(
|
||||
"resolve_inline_map_schema_in_response_property_string",
|
||||
new StringSchema().example("example")
|
||||
)
|
||||
@@ -969,10 +979,8 @@ public class InlineModelResolverTest {
|
||||
.getContent()
|
||||
.get("application/json")
|
||||
.getSchema();
|
||||
//.getProperties()
|
||||
//.get("nullable_request_body_property");
|
||||
|
||||
Schema nullableRequestBodySchema = ModelUtils.getReferencedSchema(openAPI, nullableRequestBodyReference);
|
||||
//assertEquals(nullableRequestBodySchema, "");
|
||||
Schema nullableSchema = ModelUtils.getReferencedSchema(openAPI,
|
||||
((Schema) nullableRequestBodySchema.getProperties().get("nullable_request_body_property")));
|
||||
assertTrue(nullableSchema.getNullable());
|
||||
@@ -995,11 +1003,6 @@ public class InlineModelResolverTest {
|
||||
assertNotNull(callbackRequestBodyReference.getContent().get("application/json").getSchema().get$ref());
|
||||
assertEquals("#/components/schemas/webhookNotify_request", callbackRequestBodyReference.getContent().get("application/json").getSchema().get$ref());
|
||||
|
||||
/*RequestBody resolvedCallbackRequestBody = openAPI
|
||||
.getComponents()
|
||||
.getSchemas()
|
||||
.get(ModelUtils.getSimpleRef(callbackRequestBodyReference.getContent().get("application/json").getSchema().get$ref()));*/
|
||||
|
||||
Schema callbackRequestSchemaReference = callbackRequestBodyReference
|
||||
.getContent()
|
||||
.get("application/json")
|
||||
@@ -1096,16 +1099,10 @@ public class InlineModelResolverTest {
|
||||
RequestBody requestBodyReference = openAPI.getPaths().get("/resolve_inline_request_body_allof").getPost().getRequestBody();
|
||||
assertEquals("#/components/schemas/resolveInlineRequestBodyAllOf_request",
|
||||
requestBodyReference.getContent().get("application/json").getSchema().get$ref());
|
||||
//assertEquals("#/components/schemas/resolveInlineRequestBodyAllOf_request", requestBodyReference.get$ref());
|
||||
|
||||
ComposedSchema allOfModel = (ComposedSchema) openAPI.getComponents().getSchemas().get("resolveInlineRequestBodyAllOf_request");
|
||||
assertEquals(null, allOfModel.getAllOf().get(0).get$ref());
|
||||
assertEquals(2, allOfModel.getAllOf().get(0).getProperties().size());
|
||||
|
||||
//Schema allOfModel = ModelUtils.getReferencedSchema(openAPI, requestBodyReference.get$ref());
|
||||
|
||||
//RequestBody referencedRequestBody = ModelUtils.getReferencedRequestBody(openAPI, requestBodyReference);
|
||||
//assertTrue(referencedRequestBody.getRequired());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ConfluenceWikiTest {
|
||||
public void converterTest() {
|
||||
final StringSchema enumSchema = new StringSchema();
|
||||
enumSchema.setEnum(Arrays.asList("VALUE1", "VALUE2", "VALUE3"));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final ConfluenceWikiCodegen codegen = new ConfluenceWikiCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -62,7 +62,7 @@ public class ConfluenceWikiTest {
|
||||
public void converterInArrayTest() {
|
||||
final ArraySchema enumSchema = new ArraySchema().items(
|
||||
new StringSchema().addEnumItem("Aaaa").addEnumItem("Bbbb"));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new ConfluenceWikiCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -95,7 +95,7 @@ public class ConfluenceWikiTest {
|
||||
final ArraySchema enumSchema = new ArraySchema().items(
|
||||
new ArraySchema().items(
|
||||
new StringSchema().addEnumItem("Aaaa").addEnumItem("Bbbb")));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new ConfluenceWikiCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CppTinyBaseTest {
|
||||
|
||||
// Arrange
|
||||
Schema schemaModel = testSchema();
|
||||
schemaModel.addProperties("id", new IntegerSchema().format("int64"));
|
||||
schemaModel.addProperty("id", new IntegerSchema().format("int64"));
|
||||
|
||||
|
||||
// Then we generated a codemodel, with the cpp tiny code generator.
|
||||
|
||||
@@ -13,7 +13,7 @@ public class CppTinyServiceServiceTest extends CppTinyBaseTest {
|
||||
public void intTypeIsLong() {
|
||||
// Arrange
|
||||
Schema schema = testSchema();
|
||||
schema.addProperties("id", new IntegerSchema().format("int64"));
|
||||
schema.addProperty("id", new IntegerSchema().format("int64"));
|
||||
|
||||
// Act
|
||||
CodegenModel model_to_be_generated = makeCodeGenFrom(schema);
|
||||
|
||||
@@ -115,9 +115,9 @@ public class JavaClientCodegenTest {
|
||||
body3.setDescription("A list of points");
|
||||
body3.setContent(new Content().addMediaType("application/json", new MediaType().schema(new ArraySchema().items(new ObjectSchema().$ref("#/components/schemas/Point")))));
|
||||
ObjectSchema point = new ObjectSchema();
|
||||
point.addProperties("message", new StringSchema());
|
||||
point.addProperties("x", new IntegerSchema().format(SchemaTypeUtil.INTEGER32_FORMAT));
|
||||
point.addProperties("y", new IntegerSchema().format(SchemaTypeUtil.INTEGER32_FORMAT));
|
||||
point.addProperty("message", new StringSchema());
|
||||
point.addProperty("x", new IntegerSchema().format(SchemaTypeUtil.INTEGER32_FORMAT));
|
||||
point.addProperty("y", new IntegerSchema().format(SchemaTypeUtil.INTEGER32_FORMAT));
|
||||
CodegenParameter codegenParameter3 = codegen.fromRequestBody(body3, new HashSet<String>(), null);
|
||||
Assert.assertEquals(codegenParameter3.description, "A list of points");
|
||||
Assert.assertEquals(codegenParameter3.dataType, "List<Point>");
|
||||
|
||||
@@ -87,15 +87,15 @@ public class JavaInheritanceTest {
|
||||
@Test(description = "composed model has the required attributes on the child")
|
||||
public void javaInheritanceWithRequiredAttributesOnAllOfObject() {
|
||||
Schema parent = new ObjectSchema()
|
||||
.addProperties("a", new StringSchema())
|
||||
.addProperties("b", new StringSchema())
|
||||
.addProperty("a", new StringSchema())
|
||||
.addProperty("b", new StringSchema())
|
||||
.addRequiredItem("a")
|
||||
.name("Parent");
|
||||
Schema child = new ComposedSchema()
|
||||
.addAllOfItem(new Schema().$ref("Parent"))
|
||||
.addAllOfItem(new ObjectSchema()
|
||||
.addProperties("c", new StringSchema())
|
||||
.addProperties("d", new StringSchema())
|
||||
.addProperty("c", new StringSchema())
|
||||
.addProperty("d", new StringSchema())
|
||||
.addRequiredItem("a")
|
||||
.addRequiredItem("c"))
|
||||
.name("Child");
|
||||
@@ -136,15 +136,15 @@ public class JavaInheritanceTest {
|
||||
@Test(description = "composed model has the required attributes for both parent & child")
|
||||
public void javaInheritanceWithRequiredAttributesOnComposedObject() {
|
||||
Schema parent = new ObjectSchema()
|
||||
.addProperties("a", new StringSchema())
|
||||
.addProperties("b", new StringSchema())
|
||||
.addProperty("a", new StringSchema())
|
||||
.addProperty("b", new StringSchema())
|
||||
.addRequiredItem("a")
|
||||
.name("Parent");
|
||||
Schema child = new ComposedSchema()
|
||||
.addAllOfItem(new Schema().$ref("Parent"))
|
||||
.addAllOfItem(new ObjectSchema()
|
||||
.addProperties("c", new StringSchema())
|
||||
.addProperties("d", new StringSchema()))
|
||||
.addProperty("c", new StringSchema())
|
||||
.addProperty("d", new StringSchema()))
|
||||
.name("Child")
|
||||
.addRequiredItem("a")
|
||||
.addRequiredItem("c");
|
||||
|
||||
@@ -38,7 +38,7 @@ public class JavaModelEnumTest {
|
||||
public void converterTest() {
|
||||
final StringSchema enumSchema = new StringSchema();
|
||||
enumSchema.setEnum(Arrays.asList("VALUE1", "VALUE2", "VALUE3"));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -61,7 +61,7 @@ public class JavaModelEnumTest {
|
||||
public void converterInArrayTest() {
|
||||
final ArraySchema enumSchema = new ArraySchema().items(
|
||||
new StringSchema().addEnumItem("Aaaa").addEnumItem("Bbbb"));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new JavaClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -94,7 +94,7 @@ public class JavaModelEnumTest {
|
||||
final ArraySchema enumSchema = new ArraySchema().items(
|
||||
new ArraySchema().items(
|
||||
new StringSchema().addEnumItem("Aaaa").addEnumItem("Bbbb")));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new JavaClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
|
||||
@@ -221,15 +221,15 @@ public class AbstractKotlinCodegenTest {
|
||||
@Test
|
||||
public void handleInheritance() {
|
||||
Schema parent = new ObjectSchema()
|
||||
.addProperties("a", new StringSchema())
|
||||
.addProperties("b", new StringSchema())
|
||||
.addProperty("a", new StringSchema())
|
||||
.addProperty("b", new StringSchema())
|
||||
.addRequiredItem("a")
|
||||
.name("Parent");
|
||||
Schema child = new ComposedSchema()
|
||||
.addAllOfItem(new Schema().$ref("Parent"))
|
||||
.addAllOfItem(new ObjectSchema()
|
||||
.addProperties("c", new StringSchema())
|
||||
.addProperties("d", new StringSchema())
|
||||
.addProperty("c", new StringSchema())
|
||||
.addProperty("d", new StringSchema())
|
||||
.addRequiredItem("c"))
|
||||
.name("Child");
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
@@ -284,20 +284,20 @@ public class AbstractKotlinCodegenTest {
|
||||
@Test(description = "Issue #10792")
|
||||
public void handleInheritanceWithObjectTypeShouldNotBeAMap() {
|
||||
Schema parent = new ObjectSchema()
|
||||
.addProperties("a", new StringSchema())
|
||||
.addProperties("b", new StringSchema())
|
||||
.addProperty("a", new StringSchema())
|
||||
.addProperty("b", new StringSchema())
|
||||
.addRequiredItem("a")
|
||||
.name("Parent");
|
||||
Schema child = new ComposedSchema()
|
||||
.addAllOfItem(new Schema().$ref("Parent"))
|
||||
.addAllOfItem(new ObjectSchema()
|
||||
.addProperties("c", new StringSchema())
|
||||
.addProperties("d", new StringSchema())
|
||||
.addProperty("c", new StringSchema())
|
||||
.addProperty("d", new StringSchema())
|
||||
.addRequiredItem("c"))
|
||||
.name("Child")
|
||||
.type("object"); // Without the object type it is not wrongly recognized as map
|
||||
Schema mapSchema = new ObjectSchema()
|
||||
.addProperties("a", new StringSchema())
|
||||
.addProperty("a", new StringSchema())
|
||||
.additionalProperties(Boolean.TRUE)
|
||||
.name("MapSchema")
|
||||
.type("object");
|
||||
|
||||
@@ -51,9 +51,9 @@ public class ScalaGatlingCodegenTest {
|
||||
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("createdAt", new DateTimeSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
final OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Swift5ModelEnumTest {
|
||||
final StringSchema enumSchema = new StringSchema();
|
||||
enumSchema.setEnum(Arrays.asList("VALUE1", "VALUE2", "VALUE3"));
|
||||
enumSchema.setDefault("VALUE2");
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new Swift5ClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -64,7 +64,7 @@ public class Swift5ModelEnumTest {
|
||||
final StringSchema enumSchema = new StringSchema();
|
||||
enumSchema.setEnum(Arrays.asList("1st", "2nd", "3rd"));
|
||||
enumSchema.setDefault("2nd");
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new Swift5ClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -88,7 +88,7 @@ public class Swift5ModelEnumTest {
|
||||
final IntegerSchema enumSchema = new IntegerSchema();
|
||||
enumSchema.setEnum(Arrays.asList(1, 2, 3));
|
||||
enumSchema.setDefault(2);
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new Swift5ClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -112,7 +112,7 @@ public class Swift5ModelEnumTest {
|
||||
final NumberSchema enumSchema = new NumberSchema();
|
||||
enumSchema.setEnum(Arrays.asList(new BigDecimal(10), new BigDecimal(100), new BigDecimal(1000)));
|
||||
enumSchema.setDefault(new BigDecimal((100)));
|
||||
final Schema model = new Schema().type("object").addProperties("name", enumSchema);
|
||||
final Schema model = new Schema().type("object").addProperty("name", enumSchema);
|
||||
|
||||
final DefaultCodegen codegen = new Swift5ClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
|
||||
@@ -35,13 +35,13 @@ public class Swift5ModelTest {
|
||||
public void simpleModelTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("binary", new BinarySchema())
|
||||
.addProperties("byte", new ByteArraySchema())
|
||||
.addProperties("uuid", new UUIDSchema())
|
||||
.addProperties("dateOfBirth", new DateSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("createdAt", new DateTimeSchema())
|
||||
.addProperty("binary", new BinarySchema())
|
||||
.addProperty("byte", new ByteArraySchema())
|
||||
.addProperty("uuid", new UUIDSchema())
|
||||
.addProperty("dateOfBirth", new DateSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name")
|
||||
.discriminator(new Discriminator().propertyName("test"));
|
||||
@@ -126,13 +126,13 @@ public class Swift5ModelTest {
|
||||
public void useCustomDateTimeTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("binary", new BinarySchema())
|
||||
.addProperties("byte", new ByteArraySchema())
|
||||
.addProperties("uuid", new UUIDSchema())
|
||||
.addProperties("dateOfBirth", new DateSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("createdAt", new DateTimeSchema())
|
||||
.addProperty("binary", new BinarySchema())
|
||||
.addProperty("byte", new ByteArraySchema())
|
||||
.addProperty("uuid", new UUIDSchema())
|
||||
.addProperty("dateOfBirth", new DateSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name")
|
||||
.discriminator(new Discriminator().propertyName("test"));
|
||||
|
||||
@@ -74,7 +74,7 @@ public class TypeScriptClientCodegenTest {
|
||||
.uniqueItems(true);
|
||||
final Schema model = new ObjectSchema()
|
||||
.description("an object has an array with uniqueItems")
|
||||
.addProperties("uniqueArray", uniqueArray)
|
||||
.addProperty("uniqueArray", uniqueArray)
|
||||
.addRequiredItem("uniqueArray");
|
||||
|
||||
final DefaultCodegen codegen = new TypeScriptClientCodegen();
|
||||
@@ -92,7 +92,7 @@ public class TypeScriptClientCodegenTest {
|
||||
inner.setAdditionalProperties(true);
|
||||
|
||||
final Schema root = new ObjectSchema()
|
||||
.addProperties("inner", inner);
|
||||
.addProperty("inner", inner);
|
||||
|
||||
final DefaultCodegen codegen = new TypeScriptClientCodegen();
|
||||
final OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", root);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TypeScriptClientModelTest {
|
||||
|
||||
@Test(description = "convert an any of with array oneof model")
|
||||
public void objectPropertyAnyOfWithArrayOneOfModelTest() {
|
||||
final Schema schema = new ObjectSchema().addProperties("value",
|
||||
final Schema schema = new ObjectSchema().addProperty("value",
|
||||
new ComposedSchema().addAnyOfItem(new StringSchema()).addAnyOfItem(new ArraySchema()
|
||||
.items(new ComposedSchema()
|
||||
.addOneOfItem(new StringSchema())
|
||||
|
||||
@@ -56,11 +56,11 @@ public class TypeScriptFetchModelTest {
|
||||
public void simpleModelTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("birthDate", new DateSchema())
|
||||
.addProperties("active", new BooleanSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("createdAt", new DateTimeSchema())
|
||||
.addProperty("birthDate", new DateSchema())
|
||||
.addProperty("active", new BooleanSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
|
||||
@@ -125,11 +125,11 @@ public class TypeScriptFetchModelTest {
|
||||
public void simpleModelWithStringDateTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("birthDate", new DateSchema())
|
||||
.addProperties("active", new BooleanSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("createdAt", new DateTimeSchema())
|
||||
.addProperty("birthDate", new DateSchema())
|
||||
.addProperty("active", new BooleanSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
|
||||
@@ -212,11 +212,11 @@ public class TypeScriptFetchModelTest {
|
||||
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", integerSchema)
|
||||
.addProperties("name", stringSchema)
|
||||
.addProperties("createdAt", dateTimeSchema)
|
||||
.addProperties("birthDate", dateSchema)
|
||||
.addProperties("active", booleanSchema)
|
||||
.addProperty("id", integerSchema)
|
||||
.addProperty("name", stringSchema)
|
||||
.addProperty("createdAt", dateTimeSchema)
|
||||
.addProperty("birthDate", dateSchema)
|
||||
.addProperty("active", booleanSchema)
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
|
||||
@@ -255,8 +255,8 @@ public class TypeScriptFetchModelTest {
|
||||
public void listPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema().items(new StringSchema()))
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("urls", new ArraySchema().items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new TypeScriptFetchClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
@@ -289,7 +289,7 @@ public class TypeScriptFetchModelTest {
|
||||
public void complexPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new Schema().$ref("#/definitions/Children"));
|
||||
.addProperty("children", new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptFetchClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
@@ -313,7 +313,7 @@ public class TypeScriptFetchModelTest {
|
||||
public void complexListPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new ArraySchema()
|
||||
.addProperty("children", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new TypeScriptFetchClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
|
||||
@@ -229,7 +229,7 @@ public class TypeScriptAngularClientCodegenTest {
|
||||
.name(modelName)
|
||||
.description("an inline model with name previously prefixed with underscore")
|
||||
.addRequiredItem("self")
|
||||
.addProperties("self", new StringSchema());
|
||||
.addProperty("self", new StringSchema());
|
||||
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("test", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
|
||||
@@ -47,11 +47,11 @@ public class TypeScriptAngularModelTest {
|
||||
public void simpleModelTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("birthDate", new DateSchema())
|
||||
.addProperties("active", new BooleanSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperty("createdAt", new DateTimeSchema())
|
||||
.addProperty("birthDate", new DateSchema())
|
||||
.addProperty("active", new BooleanSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
final DefaultCodegen codegen = new TypeScriptAngularClientCodegen();
|
||||
@@ -133,11 +133,11 @@ public class TypeScriptAngularModelTest {
|
||||
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", integerSchema)
|
||||
.addProperties("name", stringSchema)
|
||||
.addProperties("createdAt", dateTimeSchema)
|
||||
.addProperties("birthDate", dateSchema)
|
||||
.addProperties("active", booleanSchema)
|
||||
.addProperty("id", integerSchema)
|
||||
.addProperty("name", stringSchema)
|
||||
.addProperty("createdAt", dateTimeSchema)
|
||||
.addProperty("birthDate", dateSchema)
|
||||
.addProperty("active", booleanSchema)
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
|
||||
@@ -176,8 +176,8 @@ public class TypeScriptAngularModelTest {
|
||||
public void listPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema().items(new StringSchema()))
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("urls", new ArraySchema().items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new TypeScriptAngularClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
@@ -210,7 +210,7 @@ public class TypeScriptAngularModelTest {
|
||||
public void complexPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new Schema().$ref("#/definitions/Children"));
|
||||
.addProperty("children", new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new TypeScriptAngularClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
@@ -234,7 +234,7 @@ public class TypeScriptAngularModelTest {
|
||||
public void complexListPropertyTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new ArraySchema()
|
||||
.addProperty("children", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new TypeScriptAngularClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
@@ -293,7 +293,7 @@ public class TypeScriptAngularModelTest {
|
||||
|
||||
@Test(description = "convert an any of with array oneof model")
|
||||
public void objectPropertyAnyOfWithArrayOneOfModelTest() {
|
||||
final Schema schema = new ObjectSchema().addProperties("value",
|
||||
final Schema schema = new ObjectSchema().addProperty("value",
|
||||
new ComposedSchema().addAnyOfItem(new StringSchema()).addAnyOfItem(new ArraySchema()
|
||||
.items(new ComposedSchema()
|
||||
.addOneOfItem(new StringSchema())
|
||||
@@ -357,7 +357,7 @@ public class TypeScriptAngularModelTest {
|
||||
public void beginDecimalNameTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a model with a name starting with decimal")
|
||||
.addProperties("1list", new StringSchema())
|
||||
.addProperty("1list", new StringSchema())
|
||||
.addRequiredItem("1list");
|
||||
final DefaultCodegen codegen = new TypeScriptAngularClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
@@ -385,7 +385,7 @@ public class TypeScriptAngularModelTest {
|
||||
final Schema schema = new Schema()
|
||||
.description("an inline model with name previously prefixed with underscore")
|
||||
.addRequiredItem("self")
|
||||
.addProperties("self", new StringSchema());
|
||||
.addProperty("self", new StringSchema());
|
||||
|
||||
TypeScriptAngularClientCodegen codegen = new TypeScriptAngularClientCodegen();
|
||||
codegen.additionalProperties().put(TypeScriptAngularClientCodegen.FILE_NAMING, "kebab-case");
|
||||
|
||||
@@ -37,8 +37,8 @@ public class TypeScriptNestjsModelTest {
|
||||
public void simpleModelTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperty("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperty("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("birthDate", new DateSchema())
|
||||
.addRequiredItem("id")
|
||||
|
||||
@@ -171,9 +171,9 @@ public class TypeScriptNodeClientCodegenTest {
|
||||
public void postProcessOperationsWithModelsTestWithModelNameSuffix() {
|
||||
final OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
final Schema rootSchema = new ObjectSchema()
|
||||
.addProperties("child", new Schema().$ref("Child"));
|
||||
.addProperty("child", new Schema().$ref("Child"));
|
||||
final Schema childSchema = new ObjectSchema()
|
||||
.addProperties("key", new StringSchema());
|
||||
.addProperty("key", new StringSchema());
|
||||
|
||||
openAPI.getComponents()
|
||||
.addSchemas("Root", rootSchema)
|
||||
@@ -201,9 +201,9 @@ public class TypeScriptNodeClientCodegenTest {
|
||||
public void postProcessOperationsWithModelsTestWithModelNamePrefix() {
|
||||
final OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
final Schema rootSchema = new ObjectSchema()
|
||||
.addProperties("child", new Schema().$ref("Child"));
|
||||
.addProperty("child", new Schema().$ref("Child"));
|
||||
final Schema childSchema = new ObjectSchema()
|
||||
.addProperties("key", new StringSchema());
|
||||
.addProperty("key", new StringSchema());
|
||||
|
||||
openAPI.getComponents()
|
||||
.addSchemas("Root", rootSchema)
|
||||
|
||||
@@ -91,7 +91,7 @@ public class OpenApiSchemaValidationsTest {
|
||||
);
|
||||
|
||||
if (withProperties) {
|
||||
schema.addProperties("other", new ArraySchema()
|
||||
schema.addProperty("other", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Other")));
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class OpenApiSchemaValidationsTest {
|
||||
);
|
||||
|
||||
if (withProperties) {
|
||||
schema.addProperties("other", new ArraySchema()
|
||||
schema.addProperty("other", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Other")));
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class OpenApiSchemaValidationsTest {
|
||||
);
|
||||
|
||||
if (withProperties) {
|
||||
schema.addProperties("other", new ArraySchema()
|
||||
schema.addProperty("other", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Other")));
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,21 @@ paths:
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
/resolve_inline_request_body_with_title_in_chinese:
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
title: 服務條款和私隱政策
|
||||
type: object
|
||||
properties:
|
||||
just_property:
|
||||
type: string
|
||||
operationId: resolveInlineRequestBodyWithRequired
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
/non_model_request_body:
|
||||
post:
|
||||
requestBody:
|
||||
|
||||
Reference in New Issue
Block a user