|
51 | 51 | end
|
52 | 52 |
|
53 | 53 | if isempty(obj.additionalProperties) && isa(obj.additionalProperties, 'double')
|
54 |
| - obj.additionalProperties = containers.Map(); |
| 54 | + obj.additionalProperties = containers.Map({'packageVersion'}, {obj.getPackageVersion}); |
55 | 55 | end
|
56 | 56 | if ~isa(obj.additionalProperties, 'containers.Map')
|
57 | 57 | error('Client:Client', 'Expected additionalProperties property to be a containers.Map, not: %s', class(obj.additionalProperties));
|
|
71 | 71 | name string {mustBeTextScalar, mustBeNonzeroLengthText}
|
72 | 72 | end
|
73 | 73 |
|
74 |
| - [newName, modified] = matlab.lang.makeValidName(name); |
75 |
| - if modified |
76 |
| - fprintf("Warning: Invalid packageName: %s, changing to: %s\n", name, newName); |
| 74 | + % Allow for package names that have "." in them |
| 75 | + nfields = split(name, '.'); |
| 76 | + for m = 1:numel(nfields) |
| 77 | + [newName, modified] = matlab.lang.makeValidName(nfields(m)); |
| 78 | + if modified |
| 79 | + fprintf("Warning: Invalid packageName: %s, changing to: %s\n", nfields(m), newName); |
| 80 | + nfields(m) = newName; |
| 81 | + end |
77 | 82 | end
|
78 |
| - obj.packageName = newName; |
| 83 | + obj.packageName = join(nfields, '.'); |
79 | 84 | end
|
80 | 85 |
|
81 | 86 | function obj = build(obj)
|
|
144 | 149 | [tf, reportOut] = openapi.verifyPackage(obj.output, 'mode', options.mode, 'ignoredChecks', options.ignoredChecks);
|
145 | 150 | end
|
146 | 151 |
|
147 |
| - |
| 152 | + |
148 | 153 | function set.templateDir(obj, templateDir)
|
149 | 154 | arguments
|
150 | 155 | obj (1,1) openapi.build.Client
|
|
257 | 262 | copyrightNotice string {mustBeTextScalar}
|
258 | 263 | end
|
259 | 264 |
|
260 |
| - if ~startsWith(copyrightNotice, whitespacePattern + "%") |
| 265 | + if ~startsWith(copyrightNotice, whitespacePattern(0,inf) + "%") |
261 | 266 | copyrightNotice = "% " + copyrightNotice;
|
262 | 267 | end
|
263 | 268 | obj.copyrightNotice = copyrightNotice;
|
@@ -909,5 +914,18 @@ function buildAdditionalPropertiesFileEntry(obj)
|
909 | 914 | tf = false;
|
910 | 915 | end
|
911 | 916 | end
|
| 917 | + |
| 918 | + function V = getPackageVersion() |
| 919 | + % getPackageVersion Return version of the package from the VERSION file |
| 920 | + % A character vector is returned |
| 921 | + verFile = fullfile(openapiRoot(-2), 'VERSION'); |
| 922 | + if ~isfile(verFile) |
| 923 | + V = '1.0.0'; |
| 924 | + warning('Client:getPackageVersion','VERSION file not found: %s, using version 1.0.0', verFile, V); |
| 925 | + else |
| 926 | + V = char(strip(string(fileread(verFile)))); |
| 927 | + end |
| 928 | + end |
| 929 | + |
912 | 930 | end
|
913 | 931 | end %class
|
0 commit comments