Skip to content

The Consumed REST Service does not generate the NPE entities associated with the Import Mapping. #280

@acarum

Description

@acarum

User Prompt : could you generate the Consume Rest Client from https://petstore.swagger.io/v2/swagger.json ?
mxcli v0.7.0-dirty (built 2026-04-21)
Mendix Studio Pro 11.9

All the NPE related to Response Action are not generated

Image Image

`-- ============================================================
-- Petstore API - Non-Persistent Entities
-- BaseUrl: https://petstore.swagger.io/v2
-- ============================================================

CREATE NON-PERSISTENT ENTITY MyModule."PetstorePet" (
"PetId": Long,
"Name": String(200),
"Status": String(50),
"CategoryId": Long,
"CategoryName":String(200)
);
/

CREATE NON-PERSISTENT ENTITY MyModule."PetstoreTag" (
"TagId": Long,
"TagName":String(200)
);
/

CREATE NON-PERSISTENT ENTITY MyModule."PetstoreOrder" (
"OrderId": Long,
"PetId": Long,
"Quantity": Integer,
"ShipDate": DateTime,
"Status": String(50),
"IsComplete": Boolean DEFAULT false
);
/

CREATE NON-PERSISTENT ENTITY MyModule."PetstoreUser" (
"UserId": Long,
"Username": String(200),
"FirstName": String(200),
"LastName": String(200),
"Email": String(200),
"Phone": String(50),
"UserStatus": Integer
);
/

CREATE NON-PERSISTENT ENTITY MyModule."PetstoreApiResponse" (
"Code": Integer,
"ResponseType": String(200),
"Message": String(500)
);
/

-- ============================================================
-- JSON Structures (sample payloads)
-- ============================================================

CREATE JSON STRUCTURE MyModule."JSON_PetstorePet"
SNIPPET '{"id":1,"category":{"id":1,"name":"Dogs"},"name":"doggie","photoUrls":["url1"],"tags":[{"id":1,"name":"tag1"}],"status":"available"}';

CREATE JSON STRUCTURE MyModule."JSON_PetstoreOrder"
SNIPPET '{"id":1,"petId":2,"quantity":1,"shipDate":"2024-01-15T12:00:00Z","status":"placed","complete":false}';

CREATE JSON STRUCTURE MyModule."JSON_PetstoreUser"
SNIPPET '{"id":1,"username":"user1","firstName":"John","lastName":"Doe","email":"john@example.com","phone":"555-1234","userStatus":1}';

CREATE JSON STRUCTURE MyModule."JSON_PetstoreApiResponse"
SNIPPET '{"code":200,"type":"success","message":"OK"}';

-- ============================================================
-- Import Mappings (JSON -> Mendix Entity)
-- ============================================================

CREATE IMPORT MAPPING MyModule."IMM_PetstorePet"
WITH JSON STRUCTURE MyModule."JSON_PetstorePet"
{
CREATE MyModule."PetstorePet" {
"PetId" = id,
"Name" = name,
"Status" = status
}
};

CREATE IMPORT MAPPING MyModule."IMM_PetstoreOrder"
WITH JSON STRUCTURE MyModule."JSON_PetstoreOrder"
{
CREATE MyModule."PetstoreOrder" {
"OrderId" = id,
"PetId" = petId,
"Quantity" = quantity,
"ShipDate" = shipDate,
"Status" = status,
"IsComplete" = complete
}
};

CREATE IMPORT MAPPING MyModule."IMM_PetstoreUser"
WITH JSON STRUCTURE MyModule."JSON_PetstoreUser"
{
CREATE MyModule."PetstoreUser" {
"UserId" = id,
"Username" = username,
"FirstName" = firstName,
"LastName" = lastName,
"Email" = email,
"Phone" = phone,
"UserStatus" = userStatus
}
};

CREATE IMPORT MAPPING MyModule."IMM_PetstoreApiResponse"
WITH JSON STRUCTURE MyModule."JSON_PetstoreApiResponse"
{
CREATE MyModule."PetstoreApiResponse" {
"Code" = code,
"ResponseType" = type,
"Message" = message
}
};

-- ============================================================
-- Consumed REST Client
-- ============================================================

CREATE REST CLIENT MyModule."PetstoreClient" (
BaseUrl: 'https://petstore.swagger.io/v2',
Authentication: NONE
)
{
-- ---- Pet -----------------------------------------------

OPERATION "Pet_FindByStatus" {
Method: GET,
Path: '/pet/findByStatus',
Query: ($status: String),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: JSON AS $PetsJson
}

OPERATION "Pet_GetById" {
Method: GET,
Path: '/pet/{petId}',
PathParams: ($petId: Long),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: JSON AS $PetJson
}

OPERATION "Pet_Add" {
Method: POST,
Path: '/pet',
Headers: ('Content-Type' = 'application/json', 'Accept' = 'application/json'),
Body: JSON FROM $RequestBody,
Timeout: 30,
Response: JSON AS $PetJson
}

OPERATION "Pet_Update" {
Method: PUT,
Path: '/pet',
Headers: ('Content-Type' = 'application/json', 'Accept' = 'application/json'),
Body: JSON FROM $RequestBody,
Timeout: 30,
Response: JSON AS $PetJson
}

OPERATION "Pet_Delete" {
Method: DELETE,
Path: '/pet/{petId}',
PathParams: ($petId: Long),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: NONE
}

-- ---- Store ---------------------------------------------

OPERATION "Store_GetInventory" {
Method: GET,
Path: '/store/inventory',
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: JSON AS $InventoryJson
}

OPERATION "Store_PlaceOrder" {
Method: POST,
Path: '/store/order',
Headers: ('Content-Type' = 'application/json', 'Accept' = 'application/json'),
Body: JSON FROM $RequestBody,
Timeout: 30,
Response: JSON AS $OrderJson
}

OPERATION "Store_GetOrderById" {
Method: GET,
Path: '/store/order/{orderId}',
PathParams: ($orderId: Long),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: JSON AS $OrderJson
}

OPERATION "Store_DeleteOrder" {
Method: DELETE,
Path: '/store/order/{orderId}',
PathParams: ($orderId: Long),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: NONE
}

-- ---- User ----------------------------------------------

OPERATION "User_Login" {
Method: GET,
Path: '/user/login',
Query: ($username: String, $password: String),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: STRING AS $Token
}

OPERATION "User_Logout" {
Method: GET,
Path: '/user/logout',
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: NONE
}

OPERATION "User_Create" {
Method: POST,
Path: '/user',
Headers: ('Content-Type' = 'application/json', 'Accept' = 'application/json'),
Body: JSON FROM $RequestBody,
Timeout: 30,
Response: NONE
}

OPERATION "User_GetByName" {
Method: GET,
Path: '/user/{username}',
PathParams: ($username: String),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: JSON AS $UserJson
}

OPERATION "User_Update" {
Method: PUT,
Path: '/user/{username}',
PathParams: ($username: String),
Headers: ('Content-Type' = 'application/json', 'Accept' = 'application/json'),
Body: JSON FROM $RequestBody,
Timeout: 30,
Response: NONE
}

OPERATION "User_Delete" {
Method: DELETE,
Path: '/user/{username}',
PathParams: ($username: String),
Headers: ('Accept' = 'application/json'),
Timeout: 30,
Response: NONE
}
};
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions