Skip to content

Commit e37f31c

Browse files
committed
* Bug fix to Git repo generation on Windows
* Fixes issue where the data type of enum fields were not set correctly.
1 parent 1b32380 commit e37f31c

File tree

5 files changed

+58
-11
lines changed

5 files changed

+58
-11
lines changed

RELEASENOTES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# MATLAB Generator *for OpenAPI*
22

3+
## Version 3.0.2 (September 24th 2025)
4+
5+
* Fixes issue where the data type of enum fields were not set correctly.
6+
7+
## Version 3.0.1 (August 25th 2025)
8+
9+
* Bug fix to Git repo generation on Windows
10+
311
## Version 3.0.0 (July 9th 2025)
412

513
* **Breaking Change**: The MATLAB Client Generator previously named `MATLAB` was renamed to `matlab-client` (this brings the MATLAB Client generator better in line with other OpenAPI generator names, which by convention are in kebab-case, and makes a clearer distinction between the Client generator and the newly introduced Server generator which is named `matlab-server`). When generating clients using `openapi.build.Client` inside MATLAB, no changes are required, the builder has been updated to reflect this change. However, if calling generator from the command line using `npx @openapitools/openapi-generator-cli` (or by invoking the generator through `java` directly) make sure to update the command line arguments, replace `-g MATLAB` (or `--generator MATLAB`) with `-g matlab-client` (or `--generator matlab-client`).

Software/MATLAB/app/system/+openapi/+auto/@Project/Project.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,21 +324,21 @@ function printPushToExistingGitLabProject(obj, options)
324324
fprintf("Creating local git repository: %s\n", obj.path);
325325
obj.createGitIgnores();
326326
% Consider MATLAB's built in git init in >=24a (g3389057)
327-
cmd = sprintf("cd %s; git init --initial-branch=main", obj.path);
327+
cmd = sprintf('cd "%s" && git init --initial-branch=main', obj.path);
328328
[status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
329329
if status ~= 0
330330
fprintf(2, "git init failed, skipping remain repository creation steps\n");
331331
return;
332332
end
333333

334-
cmd = sprintf("cd %s; git add .", obj.path);
334+
cmd = sprintf('cd "%s" && git add .', obj.path);
335335
[status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
336336
if status ~= 0
337337
fprintf(2, "git add failed, skipping remain repository creation steps\n");
338338
return;
339339
end
340340

341-
cmd = sprintf('cd %s; git commit -m "Initial commit"', obj.path);
341+
cmd = sprintf('cd "%s" && git commit -m "Initial commit"', obj.path);
342342
[status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
343343
if status ~= 0
344344
fprintf(2, "git commit failed\n");
@@ -374,40 +374,40 @@ function printPushToExistingGitLabProject(obj, options)
374374

375375
% Repo already init'd
376376
% % Consider MATLAB's built in git init in >=24a (g3389057)
377-
% cmd = sprintf("cd %s; git init --initial-branch=main", obj.path);
377+
% cmd = sprintf('cd "%s" && git init --initial-branch=main', obj.path);
378378
% [status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
379379
% if status ~= 0
380380
% fprintf(2, "git init failed, skipping upload\n");
381381
% return;
382382
% end
383383

384384
if options.useSSH
385-
cmd = sprintf("cd %s; git remote add origin %s", obj.path, options.sshURL);
385+
cmd = sprintf('cd "%s" && git remote add origin %s', obj.path, options.sshURL);
386386
else
387-
cmd = sprintf("cd %s; git remote add origin %s", obj.path, options.httpURL);
387+
cmd = sprintf('cd "%s" && git remote add origin %s', obj.path, options.httpURL);
388388
end
389389
[status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
390390
if status ~= 0
391391
fprintf(2, "remote add failed, skipping upload\n");
392392
return;
393393
end
394394

395-
cmd = sprintf("cd %s; git add .", obj.path);
395+
cmd = sprintf('cd "%s" && git add .', obj.path);
396396
[status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
397397
if status ~= 0
398398
fprintf(2, "git add failed, skipping upload\n");
399399
return;
400400
end
401401

402402
% Already committed
403-
% cmd = sprintf('cd %s; git commit -m "Initial commit"', obj.path);
403+
% cmd = sprintf('cd "%s" && git commit -m "Initial commit"', obj.path);
404404
% [status, cmdout] = system(cmd, "-echo"); %#ok<ASGLU>
405405
% if status ~= 0
406406
% fprintf(2, "git commit failed, skipping upload\n");
407407
% return;
408408
% end
409409

410-
cmd = sprintf("cd %s; git push --progress --set-upstream origin main", obj.path);
410+
cmd = sprintf('cd "%s" && git push --progress --set-upstream origin main', obj.path);
411411
[status, cmdout] = system(cmd);
412412
if status ~= 0
413413
fprintf(2, "git push failed\nOutput:\n%s\n", cmdout);

Software/MATLAB/test/unit/DataTypes.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,45 @@ function StringEnum(testCase)
232232
testCase.verifyEqual(DT.models.MyEnum.x123.JSONValue,"123")
233233
end
234234

235+
function EnumAsField(testCase)
236+
testCase.generate('MyModel',[ ...
237+
"type: object"
238+
"properties:"
239+
" my_enum:"
240+
" type: string"
241+
" enum:"
242+
" - foo"
243+
" - 123"
244+
]);
245+
246+
247+
% Verify MyModel model was generated
248+
testCase.verifyEqual(exist('DT.models.MyModel','class'),8);
249+
% Verify that MyModel has an my_enum field and it is of the
250+
% DT.models.MyModelMy_enumEnum type
251+
m = ?DT.models.MyModel;
252+
p = m.PropertyList;
253+
testCase.verifyEqual(p.Name,'my_enum');
254+
testCase.verifyEqual(p.Validation.Class,?DT.models.MyModelMy_enumEnum)
255+
256+
% Verify enum model was generated
257+
testCase.verifyEqual(exist('DT.models.MyModelMy_enumEnum','class'),8);
258+
259+
% Verify that it is an enum
260+
m = ?DT.models.MyModelMy_enumEnum;
261+
testCase.verifyTrue(m.Enumeration)
262+
% Verify it has two values
263+
ev = m.EnumerationMemberList;
264+
testCase.verifyEqual(length(ev),2)
265+
% Verify the names are correct
266+
testCase.verifyEqual(ev(1).Name,'foo')
267+
testCase.verifyEqual(ev(2).Name,'x123')
268+
% Verify their underlying values
269+
testCase.verifyEqual(DT.models.MyModelMy_enumEnum.foo.JSONValue,"foo")
270+
testCase.verifyEqual(DT.models.MyModelMy_enumEnum.x123.JSONValue,"123")
271+
272+
end
273+
235274
function IntEnum(testCase)
236275
testCase.generate('MyEnum',[ ...
237276
"type: integer"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{^isFreeFormObject}}{{#isPrimitiveType}}{{dataType}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{^vendorExtensions.x-is-one-of-primitives}}{{#isModel}}{{modelPackage}}.{{complexType}}{{/isModel}}{{/vendorExtensions.x-is-one-of-primitives}}{{/isPrimitiveType}}{{/isFreeFormObject}}
1+
{{^isFreeFormObject}}{{#isPrimitiveType}}{{dataType}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{^vendorExtensions.x-is-one-of-primitives}}{{#complexType}}{{modelPackage}}.{{.}}{{/complexType}}{{/vendorExtensions.x-is-one-of-primitives}}{{/isPrimitiveType}}{{/isFreeFormObject}}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.0.2

0 commit comments

Comments
 (0)