1
0
mirror of https://github.com/akpaevj/OpenAPI.1C.git synced 2025-07-12 22:11:23 +02:00
This commit is contained in:
akpaevj
2023-12-16 01:57:30 +03:00
commit 10a5b024aa
65 changed files with 2262 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.metadata/

11
bom/.project Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>bom</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

295
bom/pom.xml Normal file
View File

@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2020,2021 1C-Soft LLC
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
1C-Soft LLC - initial API and implementation
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.akpaev.dt.openapi</groupId>
<artifactId>bom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>BOM</name>
<prerequisites>
<maven>3.6.0</maven>
</prerequisites>
<properties>
<tycho.version>2.7.0</tycho.version>
<tycho.extras.version>2.7.0</tycho.extras.version>
<spotbugs.maven.plugin.version>3.1.12.2</spotbugs.maven.plugin.version>
<checkstyle.version>8.5</checkstyle.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.build.timestamp.format>'v'yyyyMMdd-HHmm</maven.build.timestamp.format>
<qualifier>${maven.build.timestamp}</qualifier>
<eclipse.p2.latest>http://download.eclipse.org/releases/2022-03/</eclipse.p2.latest>
<p2repo.archive.skip>false</p2repo.archive.skip>
<org.jacoco.version>0.8.6</org.jacoco.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<resolver>p2</resolver>
<executionEnvironment>JavaSE-11</executionEnvironment>
<includePackedArtifacts>false</includePackedArtifacts>
<target>
<artifact>
<groupId>ru.akpaev.dt.openapi</groupId>
<artifactId>default</artifactId>
<version>1.0.0-SNAPSHOT</version>
</artifact>
</target>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>javax.annotation</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<strictCompilerTarget>true</strictCompilerTarget>
<useProjectSettings>true</useProjectSettings>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<verbose>true</verbose>
<optimize>true</optimize>
<compilerArgs>
<!--arg>-Werror</arg-->
<arg>-Xlint:all</arg>
<arg>-Xlint:serial</arg>
<arg>-Xlint:serial</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
<executions>
<execution>
<goals>
<goal>plugin-source</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<skip>${tycho.surefire.skipPluginTest}</skip>
<systemProperties>
<file.encoding>UTF-8</file.encoding>
<sun.jnu.encoding>UTF-8</sun.jnu.encoding>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<format>'v'yyyyMMddHHmm</format>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<repositoryName>Repository</repositoryName>
<finalName>${project.artifactId}</finalName>
<skipArchive>{p2repo.archive.skip}</skipArchive>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-eclipserun-plugin</artifactId>
<version>${tycho.extras.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<logViolationsToConsole>true</logViolationsToConsole>
<violationSeverity>warning</violationSeverity>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${org.jacoco.version}</version>
<configuration>
<excludes>
<exclude>**/MdClassPackageImpl*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/xcore-gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>export-properties</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echoproperties prefix="qualifier" destfile="${project.build.directory}/build.properties" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>find-bugs</id>
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.maven.plugin.version}</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<maxRank>9</maxRank>
<fork>true</fork>
<jvmArgs>-Xmx1536m</jvmArgs>
<maxHeap>1536</maxHeap>
<findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
</configuration>
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.0.0-beta2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

1
gitignore Normal file
View File

@ -0,0 +1 @@
.metadata

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ru.akpaev.dt.openapi.targets</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>default</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Copyright (c) 2020,2021 1C-Soft LLC.
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
1C-Soft LLC - initial API and implementation
-->
<?pde version="3.8"?><target includeMode="feature" name="1C:EDT Ruby Platform" sequenceNumber="1">
<locations>
<!-- EDT -->
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<unit id="com._1c.g5.aef.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.commons.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.edt.license.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.gumtree.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.ides.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.ides.monitoring.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.jface.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.license.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.lwt.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.properties.ui.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.bp.scheme.feature.feature.group" version="0.0.0"/>
<unit id="com.e1c.g5.v8.dt.bsl.ui.templates.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.cli.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.diagram.framework.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.erd.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.eventhandlers.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.extension.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.geographicalschema.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.handly.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.markermatcher.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.services.mobile.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.8.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.9.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.10.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.11.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.12.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.13.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.14.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.15.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.16.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.17.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.18.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.19.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.20.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.21.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.platform.support_v8.3.22.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.product.docs.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.product.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.profiling.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.rcp" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.ring.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.thirdparty.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.wst.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.xtext.runtime.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.v8.dt.xtext.ui.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.wiring.feature.feature.group" version="0.0.0"/>
<unit id="com.e1c.g5.v8.dt.javadocs" version="0.0.0"/>
<unit id="com.company1c.link.agent.core.feature.feature.group" version="0.0.0"/>
<unit id="com.company1c.link.ide.edt.feature.feature.group" version="0.0.0"/>
<unit id="com.company1c.link.agent.dependencies.feature.feature.group" version="0.0.0"/>
<unit id="de.itemis.xtext.antlr.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.babel.nls_eclipse_ru.feature.group" version="0.0.0"/>
<unit id="org.eclipse.babel.nls_technology.egit_ru.feature.group" version="0.0.0"/>
<unit id="org.eclipse.babel.nls_technology.jgit_ru.feature.group" version="0.0.0"/>
<unit id="org.eclipse.babel.nls_webtools_ru.feature.group" version="0.0.0"/>
<unit id="org.eclipse.draw2d.feature.group" version="0.0.0"/>
<unit id="org.eclipse.e4.rcp.feature.group" version="0.0.0"/>
<unit id="org.eclipse.ecf.core.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.ecf.filetransfer.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.egit.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.common.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.common.ui.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.databinding.edit.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.databinding.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.ecore.edit.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.ecore.editor.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.ecore.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.ecore.xcore.lib.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.edit.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.edit.ui.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.query.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.query.ocl.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.transaction.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.validation.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.validation.ocl.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.workspace.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.ds" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.core.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.discovery.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.extras.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.rcp.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.p2.user.ui.feature.group" version="0.0.0"/>
<unit id="org.eclipse.fx.runtime.min.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.gef.feature.group" version="0.0.0"/>
<unit id="org.eclipse.gmf.feature.group" version="0.0.0"/>
<unit id="org.eclipse.gmf.runtime.notation.feature.group" version="0.0.0"/>
<unit id="org.eclipse.gmf.runtime.thirdparty.feature.group" version="0.0.0"/>
<unit id="org.eclipse.help.feature.group" version="0.0.0"/>
<unit id="org.eclipse.jgit.feature.group" version="0.0.0"/>
<unit id="org.eclipse.jgit.http.apache.feature.group" version="0.0.0"/>
<unit id="org.eclipse.jgit.lfs.feature.group" version="0.0.0"/>
<unit id="org.eclipse.jgit.pgm.feature.group" version="0.0.0"/>
<unit id="org.eclipse.nebula.widgets.datechooser.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.nebula.widgets.formattedtext.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.nebula.widgets.grid.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.nebula.widgets.chips" version="0.0.0"/>
<unit id="org.eclipse.nebula.widgets.opal.commons" version="0.0.0"/>
<unit id="org.eclipse.ocl.feature.group" version="0.0.0"/>
<unit id="org.eclipse.platform.feature.group" version="0.0.0"/>
<unit id="org.eclipse.rcp.feature.group" version="0.0.0"/>
<unit id="org.eclipse.userstorage.feature.group" version="0.0.0"/>
<unit id="org.eclipse.xsd.edit.feature.group" version="0.0.0"/>
<unit id="org.eclipse.xsd.feature.group" version="0.0.0"/>
<unit id="org.eclipse.xtext.xbase.lib.feature.group" version="0.0.0"/>
<unit id="org.eclipse.test.performance" version="0.0.0"/>
<unit id="org.eclipse.wst.server_core.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.wst.server_ui.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.wst.server_userdoc.feature.feature.group" version="0.0.0"/>
<unit id="org.apache.derby" version="0.0.0"/>
<unit id="org.apache.xalan" version="0.0.0"/>
<unit id="org.apache.batik.script" version="0.0.0"/>
<unit id="org.apache.batik.codec" version="0.0.0"/>
<unit id="org.apache.batik.ext" version="0.0.0"/>
<unit id="org.apache.batik.transcoder" version="0.0.0"/>
<unit id="javax.servlet" version="0.0.0"/>
<repository location="https://edt.1c.ru/downloads/releases/ruby/2023.1/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.license.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/cbi/updates/license/2.0.2.v20181016-2210"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/eclipse/updates/4.16/"/>
<unit id="org.eclipse.pde.source.feature.group" version="3.14.400.v20200604-0540"/>
</location>
</locations>
</target>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2020 1C-Soft LLC
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
1C-Soft LLC - initial API and implementation
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.akpaev.dt.openapi</groupId>
<artifactId>targets</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>ru.akpaev.dt.openapi</groupId>
<artifactId>default</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-target-definition</packaging>
<name>Target Platform</name>
</project>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2020 1C-Soft LLC
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
1C-Soft LLC - initial API and implementation
-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.akpaev.dt.openapi</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>targets</artifactId>
<packaging>pom</packaging>
<name>Targets Definitions</name>
<properties>
<sonar.skip>true</sonar.skip>
</properties>
<modules>
<module>default</module>
</modules>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ru.akpaev.dt.openapi</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11

View File

@ -0,0 +1,36 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: ru.akpaev.dt.openapi;singleton:=true
Bundle-Activator: ru.akpaev.dt.openapi.Activator
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Require-Bundle: com.google.inject;bundle-version="[5.0.1,6.0.0)",
org.eclipse.ui;bundle-version="[3.201.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.18.500,4.0.0)",
org.eclipse.xtext.ui;bundle-version="[2.26.0,3.0.0)",
org.apache.log4j;bundle-version="[1.2.15,2.0.0)",
com._1c.g5.v8.dt.platform.services.ui,
com._1c.g5.v8.dt.md.ui,
com._1c.g5.v8.dt.metadata;bundle-version="14.2.0",
com._1c.g5.wiring,
com._1c.g5.v8.bm.integration;bundle-version="11.0.0",
com.fasterxml.jackson.core.jackson-annotations;bundle-version="2.10.3",
com.fasterxml.jackson.core.jackson-core;bundle-version="2.10.3",
com.fasterxml.jackson.core.jackson-databind;bundle-version="2.10.3",
com.fasterxml.jackson.dataformat.jackson-dataformat-yaml;bundle-version="2.9.7"
Import-Package: com._1c.g5.v8.bm.core;version="8.0.0",
com._1c.g5.v8.dt.bsl.model;version="[5.0.0,6.0.0)",
com._1c.g5.v8.dt.core.naming;version="7.0.0",
com._1c.g5.v8.dt.core.platform;version="11.0.0",
com._1c.g5.v8.dt.mcore;version="[7.0.0,8.0.0)",
com._1c.g5.v8.dt.mcore.impl;version="[7.0.0,8.0.0)",
com._1c.g5.v8.dt.metadata.mdclass;version="[8.0.0,9.0.0)",
org.antlr.stringtemplate;version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;version="[3.4.0,4.0.0)",
org.osgi.framework;version="[1.8.0,2.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: ru.akpaev.dt.openapi.ui
Export-Package: ru.akpaev.dt.openapi.models

View File

@ -0,0 +1 @@
$PARAM_NAME$ = Запрос.ПараметрыURL.Получить("$PARAM_NAME$");

View File

@ -0,0 +1 @@
$PARAM_NAME$ = Запрос.ПараметрыЗапроса.Получить("$PARAM_NAME$");

View File

@ -0,0 +1,7 @@
Функция $HANDLER_NAME$(Запрос)
$PARAMS_BODY$
Ответ = Новый HTTPСервисОтвет(200);
Возврат Ответ;
КонецФункции

View File

@ -0,0 +1,22 @@
DataProcessingHandler_Error_not_document_object_module = \u0414\u0430\u043D\u043D\u0430\u044F \u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u043D\u043E\u043C \u043C\u043E\u0434\u0443\u043B\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
DataProcessingHandler_Error_no_accumulation_registers = \u041D\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D \u043D\u0438 \u043E\u0434\u0438\u043D \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043E\u0432. \u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u044B \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E
DataProcessingHandler_Error = \u041E\u0448\u0438\u0431\u043A\u0430!
DataProcessingHandlerDialog_dialog_title = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
DataProcessingHandlerDialog_dialog_message = \u0417\u0430\u043F\u043E\u043B\u043D\u044F\u0435\u0442 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F \u043C\u043E\u0434\u0443\u043B\u044F \u043E\u0431\u044A\u0435\u043A\u0442\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
DataProcessingHandlerDialog_dialog_text = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
DataProcessingHandlerDialog_Registers = \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044B
DataProcessingHandlerDialog_Document_attributes = \u0420\u0435\u043A\u0432\u0438\u0437\u0438\u0442\u044B \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
DataProcessingHandlerDialog_Field = \u041F\u043E\u043B\u0435
DataProcessingHandlerDialog_Expressions = \u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435
CreateFromOpenApiSpecHandler_FailedToWriteHttpServiceModuleContent=\u041E\u0448\u0438\u0431\u043A\u0430 \u0437\u0430\u043F\u0438\u0441\u0438 \u043C\u043E\u0434\u0443\u043B\u044F HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430
CreateFromOpenApiSpecHandler_GeneratingOfHttpService=\u0413\u0435\u043D\u0435\u0440\u0430\u0446\u0438\u044F HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430
CreateFromOpenApiSpecHandler_SelectOpenAPIDialogMessage= \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 OpenAPI \u0444\u0430\u0439\u043B
CreateFromOpenApiSpecHandler_WritingOfHttpServiceModule=\u0417\u0430\u043F\u0438\u0441\u044C \u043C\u043E\u0434\u0443\u043B\u044F HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430
ImportOpenApiSettingsDialog_CreateMethodsHandlers=\u0413\u0435\u043D\u0435\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0438 \u043C\u0435\u0442\u043E\u0434\u043E\u0432
ImportOpenApiSettingsDialog_ImportSettings=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u043C\u043F\u043E\u0440\u0442\u0430 \u0441\u043F\u0435\u0446\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 OpenAPI
ImportOpenApiSettingsDialog_Name=Name
ImportOpenApiSettingsDialog_RootURL=\u041A\u043E\u0440\u043D\u0435\u0432\u043E\u0439 URL
ImportOpenApiSpecWizard_0=Http service viewer
SettingsPage_Name=\u0418\u043C\u044F
SettingsPage_RootURL=\u041A\u043E\u0440\u043D\u0435\u0432\u043E\u0439 URL
SettingsPage_SettingsPageTitle=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430

View File

@ -0,0 +1,5 @@
javacCustomEncodings.. = src/[UTF-8]
bin.includes = META-INF/,\
plugin.xml,\
plugin.properties,\
resources/

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="true"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="false"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/plugin"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-New_configuration"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms80m -Xmx4024m -Dlog4j.configuration=platform:/plugin/com._1c.g5.v8.dt.logging/log4j.properties -Dosgi.framework.extensions=org.eclipse.fx.osgi -Dosgi.module.lock.timeout=240"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com._1c.g5.v8.dt.product.application.rcp"/>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,5 @@
pluginName = \u041F\u0440\u0438\u043C\u0435\u0440 \u043F\u043B\u0430\u0433\u0438\u043D\u0430 \u0434\u043B\u044F "1C: Enterprise Development Tools"
providerName = 1C LLC
command.name = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
command.tooltip = \u0412\u044B\u0437\u044B\u0432\u0430\u0435\u0442 \u043A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F
createFromOpenApiSpec.name = \u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u043E \u0441\u043F\u0435\u0446\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 OpenAPI

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
id="ru.akpaev.dt.openapi.createfromopenapispec"
name="%createFromOpenApiSpec.name">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:com._1c.g5.v8.dt.navigator.ui.navigator.popup">
<command
commandId="ru.akpaev.dt.openapi.createfromopenapispec"
style="push">
<visibleWhen
checkEnabled="false">
<and>
<with
variable="selection">
<and>
<count
value="1">
</count>
<iterate
operator="and">
<instanceof
value="com._1c.g5.v8.dt.md.ui.navigator.adapters.HTTPServiceNavigatorAdapter$Folder">
</instanceof>
</iterate>
</and>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="ru.akpaev.dt.openapi.ExecutableExtensionFactory:ru.akpaev.dt.openapi.CreateFromOpenApiSpecHandler"
commandId="ru.akpaev.dt.openapi.createfromopenapispec">
</handler>
</extension>
</plugin>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.akpaev.dt.openapi</groupId>
<artifactId>bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>ru.akpaev.dt.openapi.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>

View File

@ -0,0 +1 @@
$PARAM_NAME$ = Запрос.ПараметрыURL.Получить("$PARAM_NAME$");

View File

@ -0,0 +1 @@
$PARAM_NAME$ = Запрос.ПараметрыЗапроса.Получить("$PARAM_NAME$");

View File

@ -0,0 +1,7 @@
Функция $HANDLER_NAME$(Запрос)
$PARAMS_BODY$
Ответ = Новый HTTPСервисОтвет(200);
Возврат Ответ;
КонецФункции

View File

@ -0,0 +1,167 @@
/**
* Copyright (C) 2020, 1C-Soft LLC
*/
package ru.akpaev.dt.openapi;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Данный класс представляет собой начальную точку в работе плагина.
* В нем следует реализовывать логику создания плагина,
* а так же необходимые действия при завершении работы плагина. <br>
*
* Так же данный класс содержит в себе ряд методов для удобного логирования ошибок
*/
public class Activator
extends AbstractUIPlugin
{
public static final String PLUGIN_ID = "ru.akpaev.dt.openapi"; //$NON-NLS-1$
private static Activator plugin;
private Injector injector;
private BundleContext bundleContext;
/**
* Получить экземпляр плагина. Через экземпляр плагина можно получать доступ к разнообразным механизмам Eclipse,
* таким как:
* <ul>
* <li>Журнал логирования ошибок плагина</li>
* <li>Механизм настройки свойств плагина</li>
* <li>Механизм дескрипторов</li>
* </ul>
*
* @return экземпляр плагина, никогда не должен возвращать <code>null</code>
*/
public static Activator getDefault()
{
return plugin;
}
public synchronized Injector getInjector()
{
if (injector == null)
injector = createInjector();
return injector;
}
private Injector createInjector()
{
try
{
return Guice.createInjector(new ExternalDependenciesModule(this));
}
catch (Exception e)
{
log(createErrorStatus("Failed to create injector for " //$NON-NLS-1$
+ getBundle().getSymbolicName(), e));
throw new RuntimeException("Failed to create injector for " //$NON-NLS-1$
+ getBundle().getSymbolicName(), e);
}
}
/**
* Запись статуса события в лог журнал плагина.
*
* @param status статус события для логирования, не может быть <code>null</code>.
* Данный статус содержит в себе информацию о произошедшем событии (ошибка выполнения,
* разнообразные предупреждения), которые были зафиксированы в логике работы плагина.
*/
public static void log(IStatus status)
{
plugin.getLog().log(status);
}
/**
* Запись исключения в лог журнал плагина
*
* @param throwable выкинутое исключение, не может быть <code>null</code>
*/
public static void logError(Throwable throwable)
{
log(createErrorStatus(throwable.getMessage(), throwable));
}
/**
* Создание записи с описанием ошибки в лог журнале плагина по выкинотому исключению и сообщению, его описывающим
*
* @param message описание выкинутого исключения, не может быть <code>null</code>
* @param throwable выкинутое исключение, может быть <code>null</code>
* @return созданное статус событие, не может быть <code>null</code>
*/
public static IStatus createErrorStatus(String message, Throwable throwable)
{
return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, throwable);
}
/**
* Создание записи с описанием предупреждения в лог журнале плагина
*
* @param message описание предупреждения, не может быть <code>null</code>
* @return созданное статус событие, не может быть <code>null</code>
*/
public static IStatus createWarningStatus(String message)
{
return new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null);
}
/**
* Создание записи с описанием предупреждения в лог журнале плагина по выкинотому исключению и сообщению,
* его описывающим
*
* @param message описание выкинутого исключения, не может быть <code>null</code>
* @param throwable выкинутое исключение, может быть <code>null</code>
* @return созданное статус событие, не может быть <code>null</code>
*/
public static IStatus createWarningStatus(final String message,
Exception throwable)
{
return new Status(IStatus.WARNING, PLUGIN_ID, 0, message, throwable);
}
/**
* Данный метод является начальной точкой работы плагина
*
* @param bundleContext объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например,
* по работе с файловыми ресурсами внутри проекта
*/
@Override
public void start(BundleContext bundleContext) throws Exception
{
super.start(bundleContext);
this.bundleContext = bundleContext;
plugin = this;
}
/**
* Данный метод вызывается при завершении работы плагина
*
* @param bundleContext объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например,
* по работе с файловыми ресурсами внутри проекта
*/
@Override
public void stop(BundleContext bundleContext) throws Exception
{
plugin = null;
super.stop(bundleContext);
}
/**
* Получить объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, по работе с
* файловыми ресурсами внутри проекта
*
* @return объект, создаваемый OSGi Framework, для доступа к разнообразным сервисам, например, по работе с
* файловыми ресурсами внутри проекта
*/
protected BundleContext getContext()
{
return bundleContext;
}
}

View File

@ -0,0 +1,175 @@
/**
*
*/
package ru.akpaev.dt.openapi;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmPlatformTransaction;
import com._1c.g5.v8.bm.integration.IBmPlatformTask;
import com._1c.g5.v8.dt.core.naming.ITopObjectFqnGenerator;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IConfigurationProvider;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.metadata.mdclass.HTTPService;
import com._1c.g5.v8.dt.platform.services.ui.SelectionContextProject;
import com.google.inject.Inject;
import ru.akpaev.dt.openapi.models.OpenApiRoot;
/**
* @author akpaev.e
*
*/
public class CreateFromOpenApiSpecHandler
extends AbstractHandler
{
@Inject
private ITopObjectFqnGenerator fqnGenerator;
@Inject
private IBmModelManager modelManager;
@Inject
private IConfigurationProvider configurationProvider;
@Inject
private IResourceLookup resourceLookup;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
IWorkbenchWindow windowInfo = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IProject project = SelectionContextProject.getContextProject(windowInfo.getActivePage());
var selectedPath = getOpenApiFilePath();
if (selectedPath == null)
return null;
var dialog = new ImportOpenApiSettingsDialog(Display.getCurrent().getActiveShell());
dialog.create();
if (dialog.open() == Window.OK)
{
OpenApiRoot root = null;
try
{
root = OpenApiRoot.deserializeFromFile(selectedPath);
}
catch (Exception e)
{
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", //$NON-NLS-1$
e.getLocalizedMessage());
}
if (root == null)
return null;
var importSettings = dialog.getSettings();
try
{
importSettings.validate();
}
catch (Exception e)
{
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", //$NON-NLS-1$
e.getLocalizedMessage());
}
var service = createNewHttpService(importSettings, root, project);
if (importSettings.getCreateHandlers())
{
try
{
writeHttpServiceModule(service, root);
}
catch (Exception e)
{
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", //$NON-NLS-1$
e.getLocalizedMessage());
}
}
}
return null;
}
private HTTPService createNewHttpService(ImportOpenApiSpecSettings settings, OpenApiRoot root, IProject project)
{
final HTTPService service = HttpServiceUtil.generateFromModel(settings.getName(), settings.getRootUrl(), root);
var configuration = configurationProvider.getConfiguration(project);
var bmNamespace = modelManager.getBmNamespace(project);
return modelManager.getGlobalEditingContext()
.execute(Messages.CreateFromOpenApiSpecHandler_GeneratingOfHttpService, null, null,
new IBmPlatformTask<HTTPService>()
{
@Override
public HTTPService execute(IBmPlatformTransaction transaction)
{
transaction.toTransactionObject(configuration).getHttpServices().add(service);
var fqn = fqnGenerator.generateStandaloneObjectFqn(service.eClass(), settings.getName());
transaction.attachTopObject(bmNamespace, (IBmObject)service, fqn);
return service;
}
});
}
private void writeHttpServiceModule(HTTPService service, OpenApiRoot root) throws Exception
{
var moduleContent = HttpServiceUtil.generateHttpServiceModuleText(service, root);
Job.create(Messages.CreateFromOpenApiSpecHandler_WritingOfHttpServiceModule, monitor -> {
IFile serviceResource = resourceLookup.getPlatformResource(service.getModule());
if (!serviceResource.exists())
{
try (InputStream stream = new ByteArrayInputStream(moduleContent.getBytes(StandardCharsets.UTF_8)))
{
serviceResource.create(stream, true, monitor);
serviceResource.touch(monitor);
}
catch (IOException | CoreException e)
{
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
Messages.CreateFromOpenApiSpecHandler_FailedToWriteHttpServiceModuleContent, e));
}
}
}).schedule();
}
private String getOpenApiFilePath()
{
var dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
dialog.setText(Messages.CreateFromOpenApiSpecHandler_SelectOpenAPIDialogMessage);
dialog.setFilterExtensions(new String[] { "*.yml" }); //$NON-NLS-1$
return dialog.open();
}
}

View File

@ -0,0 +1,31 @@
/**
*
*/
package ru.akpaev.dt.openapi;
import org.osgi.framework.Bundle;
import com._1c.g5.wiring.AbstractGuiceAwareExecutableExtensionFactory;
import com.google.inject.Injector;
/**
* @author akpaev.e
*
*/
public class ExecutableExtensionFactory
extends AbstractGuiceAwareExecutableExtensionFactory
{
@Override
protected Bundle getBundle()
{
return Activator.getDefault().getBundle();
}
@Override
protected Injector getInjector()
{
return Activator.getDefault().getInjector();
}
}

View File

@ -0,0 +1,34 @@
/**
*
*/
package ru.akpaev.dt.openapi;
import org.eclipse.core.runtime.Plugin;
import com._1c.g5.v8.dt.core.naming.ITopObjectFqnGenerator;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IConfigurationProvider;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.wiring.AbstractServiceAwareModule;
public class ExternalDependenciesModule
extends AbstractServiceAwareModule
{
public ExternalDependenciesModule(Plugin bundle)
{
super(bundle);
}
@Override
protected void doConfigure()
{
bind(IConfigurationProvider.class).toService();
bind(IBmModelManager.class).toService();
bind(ITopObjectFqnGenerator.class).toService();
bind(IV8ProjectManager.class).toService();
bind(IResourceLookup.class).toService();
}
}

View File

@ -0,0 +1,204 @@
package ru.akpaev.dt.openapi;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.UUID;
import org.antlr.stringtemplate.StringTemplate;
import com._1c.g5.v8.dt.metadata.mdclass.HTTPMethod;
import com._1c.g5.v8.dt.metadata.mdclass.HTTPService;
import com._1c.g5.v8.dt.metadata.mdclass.MdClassFactory;
import com._1c.g5.v8.dt.metadata.mdclass.Method;
import com._1c.g5.v8.dt.metadata.mdclass.URLTemplate;
import com.google.common.io.CharStreams;
import com.google.common.io.Resources;
import ru.akpaev.dt.openapi.models.OpenApiMethod;
import ru.akpaev.dt.openapi.models.OpenApiParameter;
import ru.akpaev.dt.openapi.models.OpenApiPath;
import ru.akpaev.dt.openapi.models.OpenApiRoot;
public class HttpServiceUtil
{
private static String methodTemplateContent = readResourceContent("http_method_handler_template.txt"); //$NON-NLS-1$
private static String pathParamTemplateContent = readResourceContent("get_path_param_template.txt"); //$NON-NLS-1$
private static String queryParamTemplateContent = readResourceContent("get_query_param_template.txt"); //$NON-NLS-1$
public static HTTPService generateFromModel(String name, String rootUrl, OpenApiRoot root)
{
var service = createHttpService(name, rootUrl);
root.getPaths().forEach((uri, path) -> {
var template = createUrlTemplate(uri);
service.getUrlTemplates().add(template);
path.getMethods().forEach((methodType, mDesc) -> {
var method = createMethod(template, methodType, mDesc);
template.getMethods().add(method);
});
});
return service;
}
public static String getMethodHandlerName(URLTemplate urlTemplate, Method method)
{
return urlTemplate.getName() + method.getName();
}
public static String generateHttpServiceModuleText(HTTPService service, OpenApiRoot root) throws Exception
{
var moduleBuilder = new StringBuilder();
for (var template : service.getUrlTemplates())
{
var openApiUrlTemplate = root.getPaths().get(template.getTemplate());
var openApiMethods = openApiUrlTemplate.getMethods();
for (var method : template.getMethods())
{
var methodTemplate = new StringTemplate(methodTemplateContent);
methodTemplate.setAttribute("HANDLER_NAME", method.getHandler()); //$NON-NLS-1$
// generate path and query parameters code block
var openApiMethod = openApiMethods.get(method.getHttpMethod().name().toLowerCase());
var paramsBlock = generateParamsBlock(openApiUrlTemplate, openApiMethod, root);
methodTemplate.setAttribute("PARAMS_BODY", paramsBlock); //$NON-NLS-1$
moduleBuilder.append(methodTemplate.toString());
moduleBuilder.append(System.lineSeparator());
moduleBuilder.append(System.lineSeparator());
}
}
return moduleBuilder.toString();
}
private static String generateParamsBlock(OpenApiPath path, OpenApiMethod method, OpenApiRoot root) throws Exception
{
var paramsBlockBuilder = new StringBuilder();
var templateParameters = path.getParameters();
var methodParameters = method.getParameters();
var templateHasParameters = templateParameters != null && templateParameters.size() > 0;
var methodHasParameters = templateParameters != null && templateParameters.size() > 0;
var hasParameters = templateHasParameters && methodHasParameters;
if (hasParameters)
paramsBlockBuilder.append(System.lineSeparator());
if (templateHasParameters)
{
var parametersBlock = generateParametersText(templateParameters, root);
paramsBlockBuilder.append(parametersBlock);
}
if (methodHasParameters)
{
var parametersBlock = generateParametersText(methodParameters, root);
paramsBlockBuilder.append(parametersBlock);
}
if (hasParameters)
paramsBlockBuilder.append(System.lineSeparator());
return paramsBlockBuilder.toString();
}
private static StringBuilder generateParametersText(ArrayList<OpenApiParameter> parameters, OpenApiRoot root)
throws Exception
{
var builder = new StringBuilder();
for (var openApiParameter : parameters)
{
var paramTemplateContent = ""; //$NON-NLS-1$
var in = openApiParameter.getIn();
switch (in)
{
case "path": //$NON-NLS-1$
paramTemplateContent = pathParamTemplateContent;
break;
case "query": //$NON-NLS-1$
paramTemplateContent = queryParamTemplateContent;
default:
break;
}
if (paramTemplateContent.length() > 0)
{
var paramTemplate = new StringTemplate(paramTemplateContent);
if (openApiParameter.isRef())
{
var value = root.resolveReference(openApiParameter.getRef(), openApiParameter.getClass());
paramTemplate.setAttribute("PARAM_NAME", value.getName()); //$NON-NLS-1$
}
else
paramTemplate.setAttribute("PARAM_NAME", openApiParameter.getName()); //$NON-NLS-1$
builder.append(paramTemplate.toString());
builder.append(System.lineSeparator());
}
}
return builder;
}
private static HTTPService createHttpService(String name, String rootUrl)
{
var service = MdClassFactory.eINSTANCE.createHTTPService();
service.setUuid(UUID.randomUUID());
service.setRootURL(rootUrl);
service.setName(name);
return service;
}
private static URLTemplate createUrlTemplate(String uri)
{
var template = MdClassFactory.eINSTANCE.createURLTemplate();
template.setUuid(UUID.randomUUID());
template.setName(OpenApiPath.generateUrlTemplateName(uri));
template.setTemplate(uri);
return template;
}
private static Method createMethod(URLTemplate template, String methodType, OpenApiMethod openApiMethod)
{
var method = MdClassFactory.eINSTANCE.createMethod();
method.setUuid(UUID.randomUUID());
method.setName(methodType.toLowerCase());
method.setHttpMethod(HTTPMethod.getByName(methodType.toUpperCase()));
if (openApiMethod.hasOperationId())
method.setHandler(openApiMethod.getOperationId());
else
method.setHandler(getMethodHandlerName(template, method));
return method;
}
private static String readResourceContent(String path)
{
var source = Resources.asCharSource(CreateFromOpenApiSpecHandler.class.getResource("/resources/" + path), //$NON-NLS-1$
StandardCharsets.UTF_8);
try (Reader reader = source.openBufferedStream())
{
return CharStreams.toString(reader);
}
catch (IOException | NullPointerException e)
{
return ""; //$NON-NLS-1$
}
}
}

View File

@ -0,0 +1,122 @@
/**
*
*/
package ru.akpaev.dt.openapi;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* @author akpaev.e
*
*/
public class ImportOpenApiSettingsDialog
extends TitleAreaDialog
{
private Text txtRootURL;
private Text txtName;
private Button btnCreateHandlers;
private ImportOpenApiSpecSettings settings = new ImportOpenApiSpecSettings();
public ImportOpenApiSettingsDialog(Shell parentShell)
{
super(parentShell);
}
@Override
public void create()
{
super.create();
setTitle(Messages.ImportOpenApiSettingsDialog_ImportSettings);
}
@Override
protected Control createDialogArea(Composite parent)
{
Composite area = (Composite)super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(2, false);
container.setLayout(layout);
createRootUrlInput(container);
createNameInput(container);
createCreateHandlersCheckbox(container);
return area;
}
private void createRootUrlInput(Composite container)
{
Label label = new Label(container, SWT.NONE);
label.setText(Messages.ImportOpenApiSettingsDialog_RootURL);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
txtRootURL = new Text(container, SWT.BORDER);
txtRootURL.setLayoutData(gd);
}
private void createNameInput(Composite container)
{
Label label = new Label(container, SWT.NONE);
label.setText(Messages.ImportOpenApiSettingsDialog_Name);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
txtName = new Text(container, SWT.BORDER);
txtName.setLayoutData(gd);
}
private void createCreateHandlersCheckbox(Composite container)
{
btnCreateHandlers = new Button(container, SWT.CHECK);
btnCreateHandlers.setText(Messages.ImportOpenApiSettingsDialog_CreateMethodsHandlers);
btnCreateHandlers.setSelection(true);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
gd.horizontalAlignment = GridData.FILL;
btnCreateHandlers.setLayoutData(gd);
}
@Override
protected boolean isResizable()
{
return true;
}
// save content of the Text fields because they get disposed
// as soon as the Dialog closes
private void saveInput()
{
settings.setRootUrl(txtRootURL.getText());
settings.setName(txtName.getText());
settings.setCreateHandlers(btnCreateHandlers.getSelection());
}
@Override
protected void okPressed()
{
saveInput();
super.okPressed();
}
public ImportOpenApiSpecSettings getSettings()
{
return settings;
}
}

View File

@ -0,0 +1,50 @@
/**
*
*/
package ru.akpaev.dt.openapi;
public class ImportOpenApiSpecSettings
{
private String rootUrl;
private String name;
private boolean createHandlers = false;
public String getRootUrl()
{
return rootUrl;
}
public void setRootUrl(String rootUrl)
{
this.rootUrl = rootUrl;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public boolean getCreateHandlers()
{
return createHandlers;
}
public void setCreateHandlers(boolean createHandlers)
{
this.createHandlers = createHandlers;
}
public void validate() throws Exception
{
if (name == null || name.isEmpty())
throw new Exception("Name of the service mustn't be null or empty"); //$NON-NLS-1$
if (rootUrl == null || rootUrl.isEmpty())
throw new Exception("RootURL of the service mustn't be null or empty"); //$NON-NLS-1$
}
}

View File

@ -0,0 +1,61 @@
/**
* Copyright (C) 2020, 1C-Soft LLC
*/
package ru.akpaev.dt.openapi;
import org.eclipse.osgi.util.NLS;
/**
* Данный класс - представитель локализации механизма строк в Eclipse.
*/
final class Messages
extends NLS
{
private static final String BUNDLE_NAME = "ru.akpaev.dt.openapi.messages"; //$NON-NLS-1$
public static String DataProcessingHandler_Error_not_document_object_module;
public static String DataProcessingHandler_Error_no_accumulation_registers;
public static String DataProcessingHandler_Error;
public static String DataProcessingHandlerDialog_dialog_title;
public static String DataProcessingHandlerDialog_dialog_message;
public static String DataProcessingHandlerDialog_dialog_text;
public static String DataProcessingHandlerDialog_Registers;
public static String DataProcessingHandlerDialog_Document_attributes;
public static String DataProcessingHandlerDialog_Field;
public static String DataProcessingHandlerDialog_Expressions;
public static String CreateFromOpenApiSpecHandler_FailedToWriteHttpServiceModuleContent;
public static String CreateFromOpenApiSpecHandler_GeneratingOfHttpService;
public static String CreateFromOpenApiSpecHandler_SelectOpenAPIDialogMessage;
public static String CreateFromOpenApiSpecHandler_WritingOfHttpServiceModule;
public static String ImportOpenApiSettingsDialog_CreateMethodsHandlers;
public static String ImportOpenApiSettingsDialog_ImportSettings;
public static String ImportOpenApiSettingsDialog_Name;
public static String ImportOpenApiSettingsDialog_RootURL;
public static String ImportOpenApiSpecWizard_0;
public static String SettingsPage_Name;
public static String SettingsPage_RootURL;
public static String SettingsPage_SettingsPageTitle;
static
{
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages()
{
}
}

View File

@ -0,0 +1,37 @@
/**
*
*/
package ru.akpaev.dt.openapi;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author akpaev.e
*
*/
public class StringUtil
{
public static ArrayList<String> allMatches(Pattern pattern, String input)
{
var result = new ArrayList<String>();
Matcher m = pattern.matcher(input);
while (m.find())
{
result.add(m.group());
}
return result;
}
public static StringBuilder capitalizeFirstChar(String word)
{
var result = new StringBuilder();
result.append(word.substring(0, 1).toUpperCase());
result.append(word.substring(1).toLowerCase());
return result;
}
}

View File

@ -0,0 +1,22 @@
DataProcessingHandler_Error_not_document_object_module = \u0414\u0430\u043D\u043D\u0430\u044F \u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u043D\u043E\u043C \u043C\u043E\u0434\u0443\u043B\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
DataProcessingHandler_Error_no_accumulation_registers = \u041D\u0435 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D \u043D\u0438 \u043E\u0434\u0438\u043D \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043E\u0432. \u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u044B \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E
DataProcessingHandler_Error = \u041E\u0448\u0438\u0431\u043A\u0430!
DataProcessingHandlerDialog_dialog_title = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
DataProcessingHandlerDialog_dialog_message = \u0417\u0430\u043F\u043E\u043B\u043D\u044F\u0435\u0442 \u043A\u043E\u043D\u0442\u0435\u043D\u0442 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430 \u043F\u0440\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F \u043C\u043E\u0434\u0443\u043B\u044F \u043E\u0431\u044A\u0435\u043A\u0442\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
DataProcessingHandlerDialog_dialog_text = \u041A\u043E\u043D\u0441\u0442\u0440\u0443\u043A\u0442\u043E\u0440 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432
DataProcessingHandlerDialog_Registers = \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044B
DataProcessingHandlerDialog_Document_attributes = \u0420\u0435\u043A\u0432\u0438\u0437\u0438\u0442\u044B \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430
DataProcessingHandlerDialog_Field = \u041F\u043E\u043B\u0435
DataProcessingHandlerDialog_Expressions = \u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435
CreateFromOpenApiSpecHandler_FailedToWriteHttpServiceModuleContent=\u041E\u0448\u0438\u0431\u043A\u0430 \u0437\u0430\u043F\u0438\u0441\u0438 \u043C\u043E\u0434\u0443\u043B\u044F HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430
CreateFromOpenApiSpecHandler_GeneratingOfHttpService=\u0413\u0435\u043D\u0435\u0440\u0430\u0446\u0438\u044F HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430
CreateFromOpenApiSpecHandler_SelectOpenAPIDialogMessage= \u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 OpenAPI \u0444\u0430\u0439\u043B
CreateFromOpenApiSpecHandler_WritingOfHttpServiceModule=\u0417\u0430\u043F\u0438\u0441\u044C \u043C\u043E\u0434\u0443\u043B\u044F HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430
ImportOpenApiSettingsDialog_CreateMethodsHandlers=\u0413\u0435\u043D\u0435\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0438 \u043C\u0435\u0442\u043E\u0434\u043E\u0432
ImportOpenApiSettingsDialog_ImportSettings=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u043C\u043F\u043E\u0440\u0442\u0430 \u0441\u043F\u0435\u0446\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 OpenAPI
ImportOpenApiSettingsDialog_Name=Name
ImportOpenApiSettingsDialog_RootURL=\u041A\u043E\u0440\u043D\u0435\u0432\u043E\u0439 URL
ImportOpenApiSpecWizard_0=Http service viewer
SettingsPage_Name=\u0418\u043C\u044F
SettingsPage_RootURL=\u041A\u043E\u0440\u043D\u0435\u0432\u043E\u0439 URL
SettingsPage_SettingsPageTitle=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B HTTP \u0441\u0435\u0440\u0432\u0438\u0441\u0430

View File

@ -0,0 +1,15 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
/**
* @author akpaev.e
*
*/
public interface IReferencedNode
{
public String getRef();
public boolean isRef();
}

View File

@ -0,0 +1,36 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
import java.util.LinkedHashMap;
/**
* @author akpaev.e
*
*/
public class OpenApiComponents
{
private LinkedHashMap<String, OpenApiSchema> schemas;
private LinkedHashMap<String, OpenApiParameter> parameters;
public LinkedHashMap<String, OpenApiSchema> getSchemas()
{
return schemas;
}
public void setSchemas(LinkedHashMap<String, OpenApiSchema> schemas)
{
this.schemas = schemas;
}
public LinkedHashMap<String, OpenApiParameter> getParameters()
{
return parameters;
}
public void setParameters(LinkedHashMap<String, OpenApiParameter> parameters)
{
this.parameters = parameters;
}
}

View File

@ -0,0 +1,42 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
/**
* @author akpaev.e
*
*/
public class OpenApiInfo
{
private String version;
private String title;
private String description;
public String getVersion()
{
return version;
}
public void setVersion(String version)
{
this.version = version;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
}

View File

@ -0,0 +1,52 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
import java.util.ArrayList;
/**
* @author akpaev.e
*
*/
public class OpenApiMethod
{
private String summary;
private String operationId;
private ArrayList<OpenApiParameter> parameters;
public ArrayList<OpenApiParameter> getParameters()
{
return parameters;
}
public void setParameters(ArrayList<OpenApiParameter> parameters)
{
this.parameters = parameters;
}
public String getSummary()
{
return summary;
}
public void setSummary(String summary)
{
this.summary = summary;
}
public String getOperationId()
{
return operationId;
}
public void setOperationId(String operationId)
{
this.operationId = operationId;
}
public boolean hasOperationId()
{
return operationId != null && operationId.length() > 0;
}
}

View File

@ -0,0 +1,78 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
import com.fasterxml.jackson.annotation.JsonAlias;
/**
* @author akpaev.e
*
*/
public class OpenApiParameter
implements IReferencedNode
{
@JsonAlias("$ref")
private String ref;
private String name;
private String in;
private boolean required;
private OpenApiSchema schema;
@Override
public String getRef()
{
return ref;
}
public void setRef(String ref)
{
this.ref = ref;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getIn()
{
return in;
}
public void setIn(String in)
{
this.in = in;
}
@Override
public boolean isRef()
{
return ref != null && ref.length() > 0;
}
public boolean isRequired()
{
return required;
}
public void setRequired(boolean required)
{
this.required = required;
}
public OpenApiSchema getSchema()
{
return schema;
}
public void setSchema(OpenApiSchema schema)
{
this.schema = schema;
}
}

View File

@ -0,0 +1,163 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.regex.Pattern;
import ru.akpaev.dt.openapi.StringUtil;
/**
* @author akpaev.e
*
*/
public class OpenApiPath
{
private static Pattern simplePartsPattern = Pattern.compile("(?<=(/))[.[^{}]]+?(?=(/|$))"); //$NON-NLS-1$
private static Pattern paramPartsPattern = Pattern.compile("(?<=\\{).*?(?=\\})"); //$NON-NLS-1$
private OpenApiMethod get;
private OpenApiMethod post;
private OpenApiMethod put;
private OpenApiMethod patch;
private OpenApiMethod delete;
private OpenApiMethod head;
private OpenApiMethod options;
private OpenApiMethod trace;
private ArrayList<OpenApiParameter> parameters;
public ArrayList<OpenApiParameter> getParameters()
{
return parameters;
}
public void setParameters(ArrayList<OpenApiParameter> parameters)
{
this.parameters = parameters;
}
public OpenApiMethod getGet()
{
return get;
}
public void setGet(OpenApiMethod get)
{
this.get = get;
}
public OpenApiMethod getPost()
{
return post;
}
public void setPost(OpenApiMethod post)
{
this.post = post;
}
public OpenApiMethod getPut()
{
return put;
}
public void setPut(OpenApiMethod put)
{
this.put = put;
}
public OpenApiMethod getPatch()
{
return patch;
}
public void setPatch(OpenApiMethod patch)
{
this.patch = patch;
}
public OpenApiMethod getDelete()
{
return delete;
}
public void setDelete(OpenApiMethod delete)
{
this.delete = delete;
}
public OpenApiMethod getHead()
{
return head;
}
public void setHead(OpenApiMethod head)
{
this.head = head;
}
public OpenApiMethod getOptions()
{
return options;
}
public void setOptions(OpenApiMethod options)
{
this.options = options;
}
public OpenApiMethod getTrace()
{
return trace;
}
public void setTrace(OpenApiMethod trace)
{
this.trace = trace;
}
public Map<String, OpenApiMethod> getMethods()
{
var result = new LinkedHashMap<String, OpenApiMethod>();
if (get != null)
result.put("get", getGet()); //$NON-NLS-1$
if (post != null)
result.put("post", getPost()); //$NON-NLS-1$
if (put != null)
result.put("put", getPut()); //$NON-NLS-1$
if (patch != null)
result.put("patch", getPatch()); //$NON-NLS-1$
if (delete != null)
result.put("delete", getDelete()); //$NON-NLS-1$
if (head != null)
result.put("head", getHead()); //$NON-NLS-1$
if (options != null)
result.put("options", getOptions()); //$NON-NLS-1$
if (trace != null)
result.put("trace", getTrace()); //$NON-NLS-1$
return result;
}
public static String generateUrlTemplateName(String path)
{
var simpleParts = StringUtil.allMatches(simplePartsPattern, path);
var urlParams = StringUtil.allMatches(paramPartsPattern, path);
var result = new StringBuilder();
simpleParts.forEach(part -> {
result.append(StringUtil.capitalizeFirstChar(part));
});
urlParams.forEach(part -> {
result.append("By" + StringUtil.capitalizeFirstChar(part)); //$NON-NLS-1$
});
return result.toString();
}
}

View File

@ -0,0 +1,115 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
import java.io.FileInputStream;
import java.util.Map;
import java.util.regex.Pattern;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.base.Charsets;
import ru.akpaev.dt.openapi.Activator;
import ru.akpaev.dt.openapi.StringUtil;
/**
* @author akpaev.e
*
*/
public class OpenApiRoot
{
private static Pattern inFileRefPartsPattern = Pattern.compile("(?<=/).+?(?=(/|$))"); //$NON-NLS-1$
private String fileContent;
private OpenApiInfo info;
private Map<String, OpenApiPath> paths;
private OpenApiComponents components;
public static OpenApiRoot deserializeFromFile(String path)
{
var root = new OpenApiRoot();
try (var stream = new FileInputStream(path))
{
var fileContent = new String(stream.readAllBytes(), Charsets.UTF_8);
var mapper = new ObjectMapper(new YAMLFactory());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.findAndRegisterModules();
root = mapper.readValue(fileContent, OpenApiRoot.class);
root.setFileContent(fileContent);
}
catch (Exception e)
{
Activator.logError(e);
}
return root;
}
public Map<String, OpenApiPath> getPaths()
{
return paths;
}
public void setPaths(Map<String, OpenApiPath> paths)
{
this.paths = paths;
}
public OpenApiInfo getInfo()
{
return info;
}
public void setInfo(OpenApiInfo info)
{
this.info = info;
}
public OpenApiComponents getComponents()
{
return components;
}
public void setComponents(OpenApiComponents components)
{
this.components = components;
}
public <T extends IReferencedNode> T resolveReference(String ref, Class<T> type) throws Exception
{
// this is in-file reference
if (ref.startsWith("#/")) //$NON-NLS-1$
{
var pathParts = StringUtil.allMatches(inFileRefPartsPattern, ref);
var mapper = new ObjectMapper(new YAMLFactory());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.findAndRegisterModules();
var node = mapper.readTree(fileContent);
for (var pathPart : pathParts)
node = node.get(pathPart);
var nodeText = node.toPrettyString();
T value = mapper.readValue(nodeText, type);
if (value.isRef())
return resolveReference(ref, type);
else
return value;
}
else
throw new Exception("Currently only in-file references are supported"); //$NON-NLS-1$
}
protected void setFileContent(String content)
{
fileContent = content;
}
}

View File

@ -0,0 +1,80 @@
/**
*
*/
package ru.akpaev.dt.openapi.models;
import java.util.LinkedHashMap;
import com.fasterxml.jackson.annotation.JsonAlias;
/**
* @author akpaev.e
*
*/
public class OpenApiSchema
implements IReferencedNode
{
@JsonAlias("$ref")
private String ref;
private String type;
private String format;
private LinkedHashMap<String, OpenApiSchema> properties;
private OpenApiSchema items;
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
public String getFormat()
{
return format;
}
public void setFormat(String format)
{
this.format = format;
}
public LinkedHashMap<String, OpenApiSchema> getProperties()
{
return properties;
}
public void setProperties(LinkedHashMap<String, OpenApiSchema> properties)
{
this.properties = properties;
}
@Override
public String getRef()
{
return ref;
}
public void setRef(String ref)
{
this.ref = ref;
}
@Override
public boolean isRef()
{
return ref != null && ref.length() > 0;
}
public OpenApiSchema getItems()
{
return items;
}
public void setItems(OpenApiSchema items)
{
this.items = items;
}
}