Skip to content

Commit

Permalink
fix: use post to login (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob authored Jun 9, 2020
1 parent f6d59b5 commit 301461d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/main/java/edu/isi/oba/Mapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ private void add_user_path(Path pathGenerator) {
userProperties.put("password", password);

Schema userSchema = new Schema();
userSchema.setName("User");
userSchema.setName("ObaUser");
userSchema.setType("object");
userSchema.setProperties(userProperties);
userSchema.setXml(new XML().name("User"));
schemas.put("User", userSchema);

this.paths.addPathItem("/user/login", pathGenerator.user_login());
this.paths.addPathItem("/user/login", pathGenerator.user_login(userSchema));
}

private List<OWLClass> add_owlclass_to_openapi(Query query, Path pathGenerator, OWLOntology ontology,
Expand Down
33 changes: 13 additions & 20 deletions src/main/java/edu/isi/oba/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.headers.Header;
import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.IntegerSchema;
import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.PathParameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;

Expand Down Expand Up @@ -58,23 +56,18 @@ public PathItem generate_plural(String schemaName, String schemaURI){
}


public PathItem user_login() {
public PathItem user_login(Schema schema) {
List<Parameter> parameters = new ArrayList<>();
ApiResponses apiResponses = new ApiResponses();

parameters.add(new PathParameter()
.description("The user name for login")
.name("username")
.required(true)
.in("query")
.schema(new StringSchema()));
final RequestBody requestBody = new RequestBody();

MediaType mediaType = new MediaType().schema(schema);
Content content = new Content().addMediaType("application/json", mediaType);
requestBody.setContent(content);
String requestDescription = "User credentials";
requestBody.setDescription(requestDescription);

parameters.add(new PathParameter()
.description("The password for login in clear text")
.name("password")
.required(true)
.in("query")
.schema(new StringSchema()));

Map<String, Header> headers = new HashMap<>();
headers.put("X-Rate-Limit", new Header().description("calls per hour allowed by the user").
Expand All @@ -91,13 +84,13 @@ public PathItem user_login() {
.content(new Content().addMediaType("application/json", new MediaType().schema(new StringSchema()))));

Map<String,Object> extensions = new HashMap<String, Object>();
extensions.put("x-openapi-router-controller", "openapi_server.controllers.user_controller");
extensions.put("x-openapi-router-controller", "openapi_server.controllers.default_controller");
Operation operation = new Operation()
.description("Login the user")
.extensions(extensions)
.operationId("user_login_get")
.parameters(parameters)
.requestBody(requestBody)
.responses(apiResponses);
return new PathItem().get(operation);
return new PathItem().post(operation);
}
}

0 comments on commit 301461d

Please sign in to comment.