Database model and api-first (openapi) methodology with JHipster and Java Spring

Viewed 360

I'm trying to learn and use the API-first methodology with JHipster in Java and Spring. So far I have generated yaml file describing my API in OpenAPI 3.0 specification, then I have generated Java classes like Controllers and Delegates to implement for Services etc. but I got to the point where I wonder about database model of project (db is PostgreSQL).

When or how should I add database schema for API? Should JHipster automatically generate Hibernate Entities for my project using yaml file (it didn't right now) or should I manually create database model in other tool? or should I have database model ready before creating API?

Is there a way to convert OpenAPI to Hibernate entities and import schema? What is correct workflow in JHipster in context of api-first + Hibernate/database schema?

I think the best way would be to have API ready and the rest to be done automatically.

My data type is described like this in api.yaml:

components:
schemas:
    Advert:
        description: Advert data type
        required:
            - id
            - title
            - description
            - ownerId
            - phoneNumber
            - categoryId
            - cityCode
            - creationDate
        type: object
        properties:
            id:
                description: Id
                type: integer
            title:
                description: Title of advert
                type: string
            description:
                description: Description of advert
                type: string
            ownerId:
                description: Id of owner user.
                type: integer
            phoneNumber:
                description: Advert's phone contact number.
                type: number
            viewCount:
                description: View count.
                type: integer
            categoryId:
                description: Category of advert.
                type: integer
            images:
                description: URLs of images.
                type: array
                items:
                    type: string
            cityCode:
                description: City code.
                type: string
            creationDate:
                description: Creation date.
                type: string
0 Answers
Related