Commit d7d73956 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ updated openapii and json examples

parent 6ebb2988
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -17,6 +17,11 @@ Package generated_from_model_json {
        JSON_authors authors,
        JSON_String year
    )
    
    JSON_books_item b2 (
        title = "Instance Book 2"
    )
    
    JSON_model_json JSON_instance (
        authors = [
            (
@@ -54,7 +59,18 @@ Package generated_from_model_json {
                        name = "Alfred"
                    )
                ]
            )
            ),
            b2 (),
            b2 (
            	year = "2023"
            ),
            b2 (
            	title = "2023 override"
            ),
            b2 (
            	title = "2023 override and extra year",
            	year = "2023"
            ),
        ]
    )
    Map JSON_model_json to "JSON" in SOURCE_MAPPING as JSON_SOURCE_MAPPING {
+12 −6
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ Package generated_from_ExampleAPI_yaml {
    Map ResourceData to "#/components/schemas/ResourceData" in SOURCE_MAPPING as ResourceData_SOURCE_MAPPING {
        id -> "id",
        ^size -> "size",
        created -> "created" }
        created -> "created"
    }
    Map ResourceData to "ResourceData" in TARGET_MAPPING as ResourceData_TARGET_MAPPING {
        id -> "id",
        ^size -> "size",
        created -> "created" }
        created -> "created"
    }
    Structure Subscription (
        Credentials credentials
    )
@@ -32,14 +34,18 @@ Package generated_from_ExampleAPI_yaml {
        string user
    )
    Map Subscription to "#/components/schemas/Subscription" in SOURCE_MAPPING as Subscription_SOURCE_MAPPING {
        credentials -> "credentials" }
        credentials -> "credentials"
    }
    Map Subscription to "Subscription" in TARGET_MAPPING as Subscription_TARGET_MAPPING {
        credentials -> "credentials" }
        credentials -> "credentials"
    }
    Structure AuthenticatedNotification ( )
    Map AuthenticatedNotification to "#/components/schemas/AuthenticatedNotification" in SOURCE_MAPPING as AuthenticatedNotification_SOURCE_MAPPING
    Map AuthenticatedNotification to "AuthenticatedNotification" in TARGET_MAPPING as AuthenticatedNotification_TARGET_MAPPING
    Map Credentials to "#/components/schemas/Credentials" in SOURCE_MAPPING as Credentials_SOURCE_MAPPING {
        user -> "user" }
        user -> "user"
    }
    Map Credentials to "Credentials" in TARGET_MAPPING as Credentials_TARGET_MAPPING {
        user -> "user" }
        user -> "user"
    }
}
 No newline at end of file
+272 −0
Original line number Diff line number Diff line
openapi: 3.0.0
info:
  title: ReqRes API
  description: Fake data CRUD API
  version: 1.00
servers:
  - url: https://reqres.in/api
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        email:
          type: string
        first_name:
          type: string
        last_name:
          type: string
        avatar:
          type: string
    UnknownResource:
      type: object
      properties:
        id: 
          type: integer
        name:
          type: string
        year:
          type: integer
        color:
          type: string
        pantone_value:
          type: string
paths:
  /{resource}:
    get:
      summary: Fetches a resource list
      parameters:
        - in: query
          name: page
          schema:
            type: integer
        - in: query
          name: per_page
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: 
                    type: integer
                  per_page:
                    type: integer
                  total:
                    type: integer
                  total_pages:
                    type: integer
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/UnknownResource"
  /users:
    get:
      summary: Fetches a user list
      parameters:
        - in: query
          name: page
          schema:
            type: integer
        - in: query
          name: per_page
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: 
                    type: integer
                  per_page:
                    type: integer
                  total:
                    type: integer
                  total_pages:
                    type: integer
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/User"
  /users/{id}:
    get:
      summary: Fetches a user
      parameters:
        - in: path
          name: id
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: 
                    $ref: "#/components/schemas/User"
    put:
      summary: Updates a user
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    patch:
      summary: Updates a user
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    delete:
      summary: Deletes a user
      responses:
        '204':
          description: Success
  /{resource}/{id}:
    get:
      summary: Fetches an unknown resource
      parameters:
        - in: path
          name: id
          schema:
            type: integer
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: 
                    $ref: "#/components/schemas/UnknownResource"
    put:
      summary: Updates an unknown resource
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    patch:
      summary: Updates an unknown resource
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  updatedAt:
                    type: string
    delete:
      summary: Deletes an unknown resource
      responses:
        '204':
          description: Success
  /login:
    post:
      summary: Creates a session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: 
                type: object
                properties:
                  token:
                    type: string
        '400':
          description: Login error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /register:
    post:
      summary: Creates a user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: 
                type: object
                properties:
                  id:
                    type: string
                  token:
                    type: string
        '400':
          description: Register error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /logout:
    post:
      summary: Ends a session
      responses:
        '200':
          description: Success
+195 −0
Original line number Diff line number Diff line
Package generated_from_reqres_yaml {
    Type String
    Type TODO_RESOLVE_REFERENCED
    Use "reqres.yaml" as SOURCE_MAPPING
    Use "generated/java" as TARGET_MAPPING
    Structure User (
        integer id,
        string email,
        string first_name,
        string last_name,
        string avatar
    )
    Type integer
    Type string
    Map User to "#/components/schemas/User" in SOURCE_MAPPING as User_SOURCE_MAPPING {
        id -> "id",
        email -> "email",
        first_name -> "first_name",
        last_name -> "last_name",
        avatar -> "avatar"
    }
    Map User to "User" in TARGET_MAPPING as User_TARGET_MAPPING {
        id -> "id",
        email -> "email",
        first_name -> "first_name",
        last_name -> "last_name",
        avatar -> "avatar"
    }
    Structure UnknownResource (
        integer id,
        string name,
        integer year,
        string color,
        string pantone_value
    )
    Map UnknownResource to "#/components/schemas/UnknownResource" in SOURCE_MAPPING as UnknownResource_SOURCE_MAPPING {
        id -> "id",
        name -> "name",
        year -> "year",
        color -> "color",
        pantone_value -> "pantone_value"
    }
    Map UnknownResource to "UnknownResource" in TARGET_MAPPING as UnknownResource_TARGET_MAPPING {
        id -> "id",
        name -> "name",
        year -> "year",
        color -> "color",
        pantone_value -> "pantone_value"
    }
    Structure inline_response_200 (
        integer page,
        integer per_page,
        integer total,
        integer total_pages,
        inline_response_200______item data
    )
    Collection inline_response_200______item of inline_response_200______itemUnknownResource
    Structure inline_response_200______itemUnknownResource (
        integer id,
        string name,
        integer year,
        string color,
        string pantone_value
    )
    Map inline_response_200 to "#/components/schemas/inline_response_200" in SOURCE_MAPPING as inline_response_200_SOURCE_MAPPING {
        page -> "page",
        per_page -> "per_page",
        total -> "total",
        total_pages -> "total_pages",
        data -> "data"
    }
    Map inline_response_200 to "inline_response_200" in TARGET_MAPPING as inline_response_200_TARGET_MAPPING {
        page -> "page",
        per_page -> "per_page",
        total -> "total",
        total_pages -> "total_pages",
        data -> "data"
    }
    Structure inline_response_200_1 (
        integer page,
        integer per_page,
        integer total,
        integer total_pages,
        inline_response_200_1______item data
    )
    Collection inline_response_200_1______item of inline_response_200_1______itemUser
    Structure inline_response_200_1______itemUser (
        integer id,
        string email,
        string first_name,
        string last_name,
        string avatar
    )
    Map inline_response_200_1 to "#/components/schemas/inline_response_200_1" in SOURCE_MAPPING as inline_response_200_1_SOURCE_MAPPING {
        page -> "page",
        per_page -> "per_page",
        total -> "total",
        total_pages -> "total_pages",
        data -> "data"
    }
    Map inline_response_200_1 to "inline_response_200_1" in TARGET_MAPPING as inline_response_200_1_TARGET_MAPPING {
        page -> "page",
        per_page -> "per_page",
        total -> "total",
        total_pages -> "total_pages",
        data -> "data"
    }
    Structure inline_response_200_2 (
        User data
    )
    Map inline_response_200_2 to "#/components/schemas/inline_response_200_2" in SOURCE_MAPPING as inline_response_200_2_SOURCE_MAPPING {
        data -> "data"
    }
    Map inline_response_200_2 to "inline_response_200_2" in TARGET_MAPPING as inline_response_200_2_TARGET_MAPPING {
        data -> "data"
    }
    Structure inline_response_200_3 (
        string updatedAt
    )
    Map inline_response_200_3 to "#/components/schemas/inline_response_200_3" in SOURCE_MAPPING as inline_response_200_3_SOURCE_MAPPING {
        updatedAt -> "updatedAt"
    }
    Map inline_response_200_3 to "inline_response_200_3" in TARGET_MAPPING as inline_response_200_3_TARGET_MAPPING {
        updatedAt -> "updatedAt"
    }
    Structure inline_response_200_4 (
        UnknownResource data
    )
    Map inline_response_200_4 to "#/components/schemas/inline_response_200_4" in SOURCE_MAPPING as inline_response_200_4_SOURCE_MAPPING {
        data -> "data"
    }
    Map inline_response_200_4 to "inline_response_200_4" in TARGET_MAPPING as inline_response_200_4_TARGET_MAPPING {
        data -> "data"
    }
    Structure login_body (
        string username,
        string email,
        string password
    )
    Map login_body to "#/components/schemas/login_body" in SOURCE_MAPPING as login_body_SOURCE_MAPPING {
        username -> "username",
        email -> "email",
        password -> "password"
    }
    Map login_body to "login_body" in TARGET_MAPPING as login_body_TARGET_MAPPING {
        username -> "username",
        email -> "email",
        password -> "password"
    }
    Structure inline_response_200_5 (
        string token
    )
    Map inline_response_200_5 to "#/components/schemas/inline_response_200_5" in SOURCE_MAPPING as inline_response_200_5_SOURCE_MAPPING {
        token -> "token"
    }
    Map inline_response_200_5 to "inline_response_200_5" in TARGET_MAPPING as inline_response_200_5_TARGET_MAPPING {
        token -> "token"
    }
    Structure inline_response_400 (
        string error
    )
    Map inline_response_400 to "#/components/schemas/inline_response_400" in SOURCE_MAPPING as inline_response_400_SOURCE_MAPPING {
        error -> "error"
    }
    Map inline_response_400 to "inline_response_400" in TARGET_MAPPING as inline_response_400_TARGET_MAPPING {
        error -> "error"
    }
    Structure register_body (
        string username,
        string email,
        string password
    )
    Map register_body to "#/components/schemas/register_body" in SOURCE_MAPPING as register_body_SOURCE_MAPPING {
        username -> "username",
        email -> "email",
        password -> "password"
    }
    Map register_body to "register_body" in TARGET_MAPPING as register_body_TARGET_MAPPING {
        username -> "username",
        email -> "email",
        password -> "password"
    }
    Structure inline_response_200_6 (
        string id,
        string token
    )
    Map inline_response_200_6 to "#/components/schemas/inline_response_200_6" in SOURCE_MAPPING as inline_response_200_6_SOURCE_MAPPING {
        id -> "id",
        token -> "token"
    }
    Map inline_response_200_6 to "inline_response_200_6" in TARGET_MAPPING as inline_response_200_6_TARGET_MAPPING {
        id -> "id",
        token -> "token"
    }
}
 No newline at end of file