Added root object names for better api first code generation

This commit is contained in:
Daniel López García
2021-12-17 11:55:40 +01:00
parent f3f338ae0e
commit 0469142d05
3 changed files with 67 additions and 49 deletions
+15 -6
View File
@@ -22,12 +22,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
type: array $ref: '#/components/schemas/SimilarProducts'
description: List of productIds similar to a given one ordered by similarity
minItems: 0
uniqueItems: true
items:
type: integer
'/product/{productId}': '/product/{productId}':
parameters: parameters:
- schema: - schema:
@@ -45,6 +40,20 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/ProductDetail'
'404':
description: Product Not found
components:
schemas:
SimilarProducts:
type: array
description: 'List of similar product Ids to a given one ordered by similarity'
minItems: 0
uniqueItems: true
items:
type: string
example: ["1","2","3"]
ProductDetail:
description: 'Product detail' description: 'Product detail'
type: object type: object
properties: properties:
+2 -2
View File
@@ -1,7 +1,7 @@
# Backend dev technical test # Backend dev technical test
We want to offer a new feature to our customers showing similar products to the one they are seeing. To do this we agreed with our front-end applications to create a new REST API that will provide them the product detail of similar products to a given one. [Here](./similarProducts.yaml) is the contract we agreed. We want to offer a new feature to our customers showing similar products to the one they are currently seeing. To do this we agreed with our front-end applications to create a new REST API operation that will provide them the product detail of the similar products for a given one. [Here](./similarProducts.yaml) is the contract we agreed.
We already have an endpoint that provides the product Ids similar to a given one. We also have another endpoint that returns the product detail by productId. [Here](./existingApis.yaml) is the documentation of the existing APIs. We already have an endpoint that provides the product Ids similar for a given one. We also have another endpoint that returns the product detail by product Id. [Here](./existingApis.yaml) is the documentation of the existing APIs.
**Create a Spring boot application that exposes the agreed REST API on port 5000.** **Create a Spring boot application that exposes the agreed REST API on port 5000.**
+14 -5
View File
@@ -21,17 +21,21 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/SimilarProducts'
'404':
description: Product Not found
components:
schemas:
SimilarProducts:
type: array type: array
description: 'List of similar products to a given one ordered by similarity' description: 'List of similar products to a given one ordered by similarity'
minItems: 0 minItems: 0
uniqueItems: true uniqueItems: true
items: items:
$ref: '#/components/schemas/ProductDetail'
ProductDetail:
description: 'Product detail'
type: object type: object
required:
- id
- name
- price
- availability
properties: properties:
id: id:
type: string type: string
@@ -43,3 +47,8 @@ paths:
type: number type: number
availability: availability:
type: boolean type: boolean
required:
- id
- name
- price
- availability