@@ -2162,4 +2162,73 @@ public void testUseOneOfInterfaces() {
21622162 Schema items = ((ArraySchema ) openAPI .getComponents ().getSchemas ().get ("CustomOneOfArraySchema" )).getItems ();
21632163 Assert .assertEquals (items .getExtensions ().get ("x-one-of-name" ), "CustomOneOfArraySchemaOneOf" );
21642164 }
2165+
2166+ @ Test
2167+ public void testFormComposedSchema () {
2168+ OpenAPI openAPI = TestUtils .parseContent ("openapi: 3.0.1\n " +
2169+ "info:\n " +
2170+ " version: '1.0.0'\n " +
2171+ " title: the title\n " +
2172+ "\n " +
2173+ "paths:\n " +
2174+ " '/users/me':\n " +
2175+ " post:\n " +
2176+ " description: Change user password.\n " +
2177+ " operationId: changeCurrentUserPassword\n " +
2178+ " requestBody:\n " +
2179+ " required: true\n " +
2180+ " content:\n " +
2181+ " multipart/form-data:\n " +
2182+ " schema:\n " +
2183+ " $ref: '#/components/schemas/ChangePasswordRequest'\n " +
2184+ " responses:\n " +
2185+ " '200':\n " +
2186+ " description: Successful operation\n " +
2187+ " content: {}\n " +
2188+ "\n " +
2189+ "components:\n " +
2190+ " schemas:\n " +
2191+ " CommonPasswordRequest:\n " +
2192+ " type: object\n " +
2193+ " required: [ password, passwordConfirmation ]\n " +
2194+ " properties:\n " +
2195+ " password:\n " +
2196+ " type: string\n " +
2197+ " format: password\n " +
2198+ " passwordConfirmation:\n " +
2199+ " type: string\n " +
2200+ " format: password\n " +
2201+ "\n " +
2202+ " ChangePasswordRequest:\n " +
2203+ " type: object\n " +
2204+ " allOf:\n " +
2205+ " - $ref: '#/components/schemas/CommonPasswordRequest'\n " +
2206+ " - type: object\n " +
2207+ " required: [ oldPassword ]\n " +
2208+ " properties:\n " +
2209+ " oldPassword:\n " +
2210+ " type: string\n " +
2211+ " format: password\n " );
2212+
2213+ final DefaultCodegen cg = new DefaultCodegen ();
2214+ cg .setOpenAPI (openAPI );
2215+ cg .setUseOneOfInterfaces (true );
2216+ cg .preprocessOpenAPI (openAPI );
2217+
2218+ final PathItem path = openAPI .getPaths ().get ("/users/me" );
2219+ final CodegenOperation operation = cg .fromOperation (
2220+ "/users/me" ,
2221+ "post" ,
2222+ path .getPost (),
2223+ path .getServers ());
2224+ assertEquals (operation .formParams .size (), 3 ,
2225+ "The list of parameters should include inherited type" );
2226+
2227+ final List <String > names = operation .formParams .stream ()
2228+ .map (param -> param .paramName )
2229+ .collect (Collectors .toList ());
2230+ assertTrue (names .contains ("password" ));
2231+ assertTrue (names .contains ("passwordConfirmation" ));
2232+ assertTrue (names .contains ("oldPassword" ));
2233+ }
21652234}
0 commit comments