Skip to content

Commit

Permalink
JSON schema for zowe.yaml
Browse files Browse the repository at this point in the history
Signed-off-by: Leonty Chudinov <[email protected]>
  • Loading branch information
Leonty Chudinov committed Jan 31, 2022
1 parent 8399a30 commit 526c4eb
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 3 deletions.
92 changes: 90 additions & 2 deletions webClient/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webClient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"html-loader": "~0.5.5",
"monaco-editor": "^0.20.0",
"monaco-editor-webpack-plugin": "^1.9.0",
"monaco-yaml": "~3.2.1",
"rxjs": "~6.6.0",
"sass": "~1.26.0",
"sass-loader": "~8.0.0",
Expand Down
19 changes: 19 additions & 0 deletions webClient/src/app/editor/code-editor/monaco/monaco.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class MonacoService implements OnDestroy {

constructor(
@Inject(Angular2InjectionTokens.LOGGER) private log: ZLUX.ComponentLogger,
@Inject(Angular2InjectionTokens.PLUGIN_DEFINITION) private pluginDefinition: ZLUX.ContainerPluginDefinition,
private http: HttpService,
private dataAdapter: DataAdapterService,
private editorControl: EditorControlService,
Expand Down Expand Up @@ -79,6 +80,7 @@ export class MonacoService implements OnDestroy {
}
document.addEventListener("keydown", this.fileSaveListener);

this.initJsonSchemas();

//this.editorControl.saveAllFile.subscribe(() => {
//this.saveAllFile();
Expand Down Expand Up @@ -492,6 +494,23 @@ export class MonacoService implements OnDestroy {
cleanDecoration() {
this.editorControl.editor.getValue().deltaDecorations(this.decorations, []);
}

initJsonSchemas(): void {
const uri = ZoweZLUX.uriBroker.pluginResourceUri(this.pluginDefinition.getBasePlugin(), 'assets/schemas/zowe-schema.json');
(monaco.languages as any).yaml.yamlDefaults.setDiagnosticsOptions({
hover: true,
completion: true,
validate: true,
format: true,
enableSchemaRequest: true,
schemas: [
{
fileMatch: ['inmemory://**zowe.yaml/**'],
uri: uri
},
],
});
}
}

/*
Expand Down
74 changes: 74 additions & 0 deletions webClient/src/app/zowe-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "zowe_yaml_schema",
"$id": "http//zowe.org/schemas/yaml-2.0.json",
"type": "object",
"required": [
"zowe",
"externalPort"
],
"properties": {
"zowe": {
"properties": {
"setup": {
"type": "object",
"properties": {
"mvs": {
"type": "object",
"description": "MVS data set related configurations",
"properties": {
"proclib": {
"$ref": "#/$defs/dataset"
},
"parmlib": {
"$ref": "#/$defs/dataset"
},
"hlq": {
"description": "where Zowe MVS data sets will be installed",
"$ref": "#/$defs/dataset"
}
}
}
}
}
}
},
"job": {
"type": "object",
"required": [
"name",
"prefix"
],
"properties": {
"name": {
"$ref": "#/$defs/jobname"
},
"prefix": {
"type": "string"
}
}
},
"externalPort": {
"type": "integer"
},
"logDirectory": {
"type": "string"
}
},
"$defs": {
"dataset": {
"type": "string",
"minLength": 3,
"maxLength": 44
},
"jobname": {
"type": "string",
"minLength": 3,
"maxLength": 8
},
"tcpPort": {
"type": "integer",
"minimum": 1024,
"maximum": 65535
}
}
}
14 changes: 13 additions & 1 deletion webClient/webpack.build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,19 @@ var config = {
threshold: 50000,
minRatio: 0.8
})
, new MonacoWebpackPlugin({publicPath: pubPath})
, new MonacoWebpackPlugin({
publicPath: pubPath,
customLanguages: [
{
label: 'yaml',
entry: ['monaco-yaml', 'vs/basic-languages/yaml/yaml.contribution'],
worker: {
id: 'monaco-yaml/yamlWorker',
entry: 'monaco-yaml/lib/esm/yaml.worker',
},
},
],
})
]
};

Expand Down

0 comments on commit 526c4eb

Please sign in to comment.