Skip to content

Commit

Permalink
Merge pull request #127 from swisspush/develop
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
lbovet authored Apr 9, 2020
2 parents fe106d8 + ee24d8d commit 7949a4b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apikana",
"version": "0.7.9",
"version": "0.8.0",
"description": "Integrated tools for REST API design - アピ",
"main": "index.js",
"bin": {
Expand Down
4 changes: 4 additions & 0 deletions src/generate-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = {
var schemaInfos = schemaInfos(schemas);
for (var name in schemas) {
var info = schemaInfos[name];
if(!name.match(/^[A-Z_].*/)) {
log.error("Naming Check Error: Type name not capitalized "+name)
process.exit(1);
}
if (info.source === '') {
log.info('Found definition', colors.magenta(name));
var schema = schemas[name];
Expand Down
14 changes: 8 additions & 6 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,14 @@ module.exports = {

modelNames.forEach(modelName => {
var fullSchema = Object.assign({}, completeApi.definitions[modelName]);
fullSchema.$schema = 'http://json-schema.org/draft-04/schema#',
fullSchema.definitions = resolveDefinitions(fullSchema.properties, completeApi.definitions)
var fileName = modelName.replace(/([^^])([A-Z]+)/g, '$1-$2').toLowerCase() + '.json';
var outputDir = path.resolve(dest, 'model/json-schema-v4-full')
fse.mkdirsSync(outputDir);
fs.writeFileSync(path.resolve(outputDir, fileName), JSON.stringify(fullSchema, 6, 2));
if(fullSchema.type == "object") {
fullSchema.$schema = 'http://json-schema.org/draft-04/schema#',
fullSchema.definitions = resolveDefinitions(fullSchema.properties, completeApi.definitions)
var fileName = modelName.replace(/([^^])([A-Z]+)/g, '$1-$2').toLowerCase() + '.json';
var outputDir = path.resolve(dest, 'model/json-schema-v4-full')
fse.mkdirsSync(outputDir);
fs.writeFileSync(path.resolve(outputDir, fileName), JSON.stringify(fullSchema, 6, 2));
}
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/model/ts/default-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type Int=number // @type integer
/**
* <a href="https://swagger.io/docs/specification/data-models/data-types/#numbers">Number @type integer</a> as signed 64-bit long integer.
*/
export type Long=number // @type integer @minimum -9223372036854775000 @maximum 9223372036854775000 @format long
export type Long=number // @type integer @minimum -9223372036854775000 @maximum 9223372036854775000 @format int64

/**
* <a href="https://swagger.io/docs/specification/data-models/data-types/#string">String @format date-time</a>,
Expand Down
18 changes: 14 additions & 4 deletions src/plopfile_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ module.exports = function (plop, cfg) {
plop.setHelper('ConvertVersion', (version) => {
return version.replace(/-(?!.*-).*/, "-SNAPSHOT");
});

plop.setHelper('ConvertDependency', (dependencies) => {
var result = [];

for(var key in dependencies) {
const packageRoot = path.resolve(currentPath, 'node_modules', key);
if(fs.existsSync(packageRoot)) {
const packageJSON = JSON.parse(fs.readFileSync(path.resolve(packageRoot, './package.json').toString()));

if(packageJSON.hasOwnProperty('customConfig')) {

result.push({
groupId: packageJSON.customConfig.mavenGroupId,
artifactId: packageJSON.customConfig.projectName,
Expand All @@ -36,12 +36,22 @@ module.exports = function (plop, cfg) {
return result;
});

function getMajorVersion(version) {
let majorVersion = version.split(".", 1)[0];
if (majorVersion === "0") {
majorVersion = "1";
}
return majorVersion;
}

plop.setGenerator('start', {
description: '',
prompts: [],
actions: (packageJSON) => {
var actions = [];


packageJSON.customConfig.majorVersion = getMajorVersion(packageJSON.version);

packageJSON.customConfig.plugins.map(plugin => {
// by default add default templates from apikana itself
actions.push({
Expand Down
6 changes: 4 additions & 2 deletions src/scaffold/template/maven/gen/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<includes>{{pathCase customConfig.javaPackage }}/**</includes>
<includes>
<include>{{pathCase customConfig.javaPackage }}/**</include>
</includes>
</configuration>
</plugin>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
Expand Down

0 comments on commit 7949a4b

Please sign in to comment.