Skip to content
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

IL-69 Add OpenAPI for User RestApi #99

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,32 @@
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-from-product-openapi-spec</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api-specs/product-openapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>com.zufar.onlinestore.openapi.api</apiPackage>
<apiPackage>com.zufar.onlinestore.openapi.product.api</apiPackage>
<modelPackage>com.zufar.onlinestore.product.dto</modelPackage>
<supportingFilesToGenerate>
ApiUtil.java
</supportingFilesToGenerate>
<generateModels>false</generateModels>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
</configOptions>
</configuration>
</execution>
<execution>
<id>generate-from-user-openapi-spec</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api-specs/user-openapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>com.zufar.onlinestore.openapi.user.api</apiPackage>
<modelPackage>com.zufar.onlinestore.user.dto</modelPackage>
<generateModels>false</generateModels>
<configOptions>
<interfaceOnly>true</interfaceOnly>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.zufar.onlinestore.product.endpoint;

import com.zufar.onlinestore.openapi.api.ProductsApi;
import com.zufar.onlinestore.openapi.product.api.ProductsApi;
import com.zufar.onlinestore.product.api.ProductApi;
import com.zufar.onlinestore.product.dto.ProductInfoDto;
import com.zufar.onlinestore.product.dto.ProductListWithPaginationInfoDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zufar.onlinestore.user.endpoint;

import com.zufar.onlinestore.openapi.user.api.UsersApi;
import com.zufar.onlinestore.user.api.UserApi;
import com.zufar.onlinestore.user.dto.UserDto;
import lombok.RequiredArgsConstructor;
Expand All @@ -19,12 +20,13 @@
@RequiredArgsConstructor
@Validated
@RequestMapping(value = UserEndpoint.API_CUSTOMERS)
public class UserEndpoint {
public class UserEndpoint implements UsersApi {

public static final String API_CUSTOMERS = "/api/v1/users";

private final UserApi userApi;

@Override
@GetMapping("/{userId}")
public ResponseEntity<UserDto> getUserById(@PathVariable final String userId) {
log.info("Received the request to get the User with userId - {}.", userId);
Expand Down
64 changes: 64 additions & 0 deletions src/main/resources/api-specs/user-openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
openapi: "3.0.3"

info:
title: "Online-Store API"
version: "1.0.0"

servers:
- url: "http://localhost:8083"

tags:
- name: "Users"
description: "An API for getting user information"

paths:
/api/v1/users/{userId}:
get:
tags:
- "Users"
summary: "Enables to get a user by its id"
operationId: "getUserById"
parameters:
- name: "userId"
description: "the identifier of the user which is returned as the return value"
in: "path"
required: true
schema:
type: "string"
responses:
"200":
description: "OK"
content:
'*/*':
schema:
$ref: "#/components/schemas/UserDto"

components:
schemas:
AddressDto:
type: "object"
properties:
line:
type: "string"
city:
type: "string"
country:
type: "string"

UserDto:
type: "object"
properties:
firstName:
type: "string"
lastName:
type: "string"
stripeCustomerToken:
type: "string"
username:
type: "string"
email:
type: "string"
password:
type: "string"
address:
$ref: "#/components/schemas/AddressDto"
Loading