how to tell JHipster JDL to enable 'API first development'? - jhipster

When I generate a JHipster application manually, I get asked whether I want to to go with a 'API first'-approach (e.g.: Which other technologies would you like to use? > API first development using OpenAPI-generator)
How can I do the same if want to create the application with a JDL-file? e.g.:
application {
config {
baseName myapp
applicationType monolith
devDatabaseType mysql
prodDatabaseType mysql
buildTool maven
clientFramework react
enableTranslation true
nativeLanguage en
languages [en, de]
enableOpenApi true <-- What is the correct way to enable OpenAPI?
}
entities *
}

thanks to #gaƫl-marziou I found it: enableSwaggerCodegen true
jhipster export-jdl export.jh
cat export.jh
application {
config {
applicationType monolith
authenticationType jwt
baseName dummy
blueprints []
buildTool maven
cacheProvider no
clientFramework angularX
clientPackageManager npm
clientTheme flatly
clientThemeVariant dark
creationTimestamp 1616332818045
databaseType sql
devDatabaseType postgresql
dtoSuffix DTO
enableHibernateCache false
enableSwaggerCodegen true <-- this is it
enableTranslation true
jhiPrefix jhi
jhipsterVersion "7.0.0"
jwtSecretKey "xxxxxxx"
languages [en]
messageBroker false
nativeLanguage en
otherModules []
packageName com.mycompany.myapp
prodDatabaseType postgresql
reactive false
searchEngine false
serverPort 8080
serviceDiscoveryType eureka
skipClient false
skipServer false
skipUserManagement false
testFrameworks []
websocket false
withAdminUi true
}
}

Related

How can I configure Hardhat to work with RSK regtest blockchain?

I intend to develop my smart contracts in Hardhat, and to test them on RSK regtest local node. I was able to find a Truffle regtest configuration.
development: {
host: "127.0.0.1",
port: 4444,
network_id: "*"
},
What hardhat.config.js configuration do I need to run my tests on RSK regtest?
To deploy and test your smart contracts on RSK regtest yourhardhat.config.js should look as follows:
/**
* #type import('hardhat/config').HardhatUserConfig
*/
require("#nomiclabs/hardhat-waffle");
module.exports = {
solidity: "0.7.3",
defaultNetwork: "rskregtest",
networks: {
rskregtest: {
url: "http://localhost:4444/",
},
},
};
Then you'll be able to run your tests by typing in the terminal
% npx hardhat test

How to generate Graphql types for React with help of graphql-codegen when Apollo Server is in production mode?

When backend mode set to NODE_ENV: development all works perfectly, but in production mode graphql-codegen fails with error:
Local web-server error:
GraphQL introspection is not allowed by Apollo Server, but the query
contained _schema or _type. To enable introspection, pass
introspection: true to ApolloServer in production
Production web-server error:
Failed to load schema from https://example.com/graphql, reason: unable
to verify the first certificate. GraphQL Code Generator supports:
ES Modules and CommonJS exports (export as default or named export "schema")
Introspection JSON File
URL of GraphQL endpoint
Multiple files with type definitions (glob expressions)
String in config file
Front-end codegen.yml:
schema: ${REACT_APP_GRAPHQL_URL}
documents:
- './src/GraphQL/queries/query.ts'
- './src/GraphQL/mutations/mutation.ts'
overwrite: true
generates:
./src/generated/graphql.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
config:
skipTypename: false
withHooks: true
withHOC: false
withComponent: false
Front-end devDependencies:
{
"#graphql-codegen/cli": "^1.20.1",
"#graphql-codegen/typescript": "^1.20.2",
"#graphql-codegen/typescript-operations": "^1.17.14",
"#graphql-codegen/typescript-react-apollo": "^2.2.1",
}
npm scripts:
{
"generate": "graphql-codegen -r dotenv/config --watch --config codegen.yml",
"prebuild": "graphql-codegen -r dotenv/config --config codegen.yml"
}
./src/generated/ directory added to .gitignore
My solution was in add introspection plugin and separate codegen.yml file into:
codegen-generate-schema-json and
codegen-generate-typescript
devDependencies: {"#graphql-codegen/introspection": "^1.18.1"}
codegen-generate-typescript.yml:
schema: graphql.schema.json
documents:
- './src/GraphQL/queries/query.ts'
- './src/GraphQL/mutations/mutation.ts'
overwrite: true
generates:
./src/generated/graphql.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
config:
skipTypename: false
withHooks: true
withHOC: false
withComponent: false
codegen-generate-schema-json.yml:
schema: ${REACT_APP_GRAPHQL_URL}
overwrite: true
generates:
./graphql.schema.json:
plugins:
- introspection
So ./graphql.schema.json file need to be commited and used as schema source instead of URI.
Maybe you suggest the better solution?

Jhipster import-jdl controlling what gets generated

I have a simple JHipster JDL file that looks like below
entity Student {
name String,
age Integer
}
and I have this saved in a file called student.jh
Now I am trying to make use of the JHipster CLI and generate the entities needed for my dummy project. I noticed that by default JHipster ends up generating the following:
Entity classes
DTO classes
Repository classes
Service classes (I think this we can further customise by adding options as to whether we need service implementation as well)
Rest Controllers
Integration tests
Gatling tests (This I believe is configurable)
I was hoping to know if I could have JHipster skip generating the rest controllers because I would like to add custom rest controllers by hand. I know that I could merely have these controllers alone deleted (along with the Integration Tests that also get generated).
Is there any way in which this can be controlled? I have tried using all of the cli options for jhipster import-jdl but no luck yet.
here's the command I am using
jhipster import-jdl src/main/resources/student.jh
Here's the complete output
jhipster -d import-jdl src/main/resources/student.jh
INFO! Using JHipster version installed globally
DEBUG! Executing CLI only script
DEBUG! cmd: import-jdl from ./import-jdl
DEBUG! args: [object Undefined]
INFO! Executing import-jdl src/main/resources/student.jh
DEBUG! Options: debug: true, skip-install: false, interactive: false, json-only: false, ignore-application: false, ignore-deployments: false, skip-ui-grouping: false, skip-db-changelog: false, skip-sample-repository: false, skipInstall: false, jsonOnly: false, ignoreApplication: false, ignoreDeployments: false, skipUiGrouping: false, skipDbChangelog: false, skipSampleRepository: false, from-cli: true, fromCli: true, inline:
DEBUG! JDLProcessor started with files: src/main/resources/student.jh and options: debug: true, skip-install: false, interactive: false, json-only: false, ignore-application: false, ignore-deployments: false, skip-ui-grouping: false, skip-db-changelog: false, skip-sample-repository: false, skipInstall: false, jsonOnly: false, ignoreApplication: false, ignoreDeployments: false, skipUiGrouping: false, skipDbChangelog: false, skipSampleRepository: false, from-cli: true, fromCli: true
INFO! Found .yo-rc.json on path. This is an existing app
INFO! The JDL is being parsed.
DEBUG! importState exportedEntities: 1
DEBUG! importState exportedApplications: 0
DEBUG! importState exportedDeployments: 0
INFO! Found entities: Student.
INFO! The JDL has been successfully parsed
DEBUG! Applications not generated
INFO! Generating 1 entity.
DEBUG! Generator is starting
Found the .jhipster/Student.json configuration file, entity can be automatically generated!
The entity Student is being updated.
DEBUG! Generator is starting
DEBUG! Time taken to write files: 62ms
create src/main/resources/config/liquibase/changelog/20210202113651_added_entity_Student.xml
create src/main/resources/config/liquibase/fake-data/student.csv
create src/main/java/org/rationaleemotions/domain/Student.java
create src/main/java/org/rationaleemotions/web/rest/StudentResource.java
create src/main/java/org/rationaleemotions/repository/search/StudentSearchRepository.java
create src/main/java/org/rationaleemotions/repository/StudentRepository.java
create src/test/java/org/rationaleemotions/web/rest/StudentResourceIT.java
create src/test/java/org/rationaleemotions/repository/search/StudentSearchRepositoryMockConfiguration.java
create src/test/java/org/rationaleemotions/domain/StudentTest.java
force src/main/resources/config/liquibase/master.xml
DEBUG! Generator has ended
DEBUG! Generator has ended
DEBUG! Deployments not generated
INFO! Congratulations, JHipster execution is complete!
Below is the complete output of my JHipster info command
jhipster info
INFO! Using JHipster version installed globally
INFO! Executing jhipster:info
Welcome to the JHipster Information Sub-Generator
##### **JHipster Version(s)**
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
"generator-jhipster": {
"promptValues": {
"packageName": "org.rationaleemotions"
},
"jhipsterVersion": "6.10.5",
"applicationType": "microservice",
"baseName": "necropolis",
"packageName": "org.rationaleemotions",
"packageFolder": "org/rationaleemotions",
"serverPort": "8081",
"authenticationType": "oauth2",
"cacheProvider": "hazelcast",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mariadb",
"prodDatabaseType": "mariadb",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
"embeddableLaunchScript": false,
"creationTimestamp": 1611077969383,
"testFrameworks": [],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": false,
"clientPackageManager": "npm",
"blueprints": [],
"skipClient": true,
"skipUserManagement": true
}
}
</pre>
</details>
##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
<details>
<summary>JDL entity definitions</summary>
<pre>
entity Student {
name String,
age Integer
}
microservice Student with necropolis
clientRootFolder Student with necropolis
</pre>
</details>
##### **Environment and Tools**
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
git version 2.30.0
node: v14.15.3
yeoman: 3.1.1
Docker version 20.10.0, build 7287ab3
docker-compose version 1.27.4, build 40524192
identical .jhipster/Student.json
INFO! Congratulations, JHipster execution is complete!

Metrics/Actuator not working in jHipster project after SpringBoot version upgrade

Project Details:
Was generated with Jhipster 4.3.0
Now, SpringBoot version upgraded from 1.5.2 to 2.2.6
After SpringBoot version upgrade, Administration>Metrics does not work.
Application.yml -Metrics
management:
server:
servlet:
context-path: /management
endpoints:
web:
base-path: /management
exposure:
include: ['configprops', 'env', 'health', 'info', 'metrics', 'jhimetrics', 'logfile', 'loggers', 'prometheus', 'threaddump']
endpoint:
jhimetrics:
enabled: true
metrics:
enable:
http: true
jvm: true
logback: true
process: true
system: true
On hitting http://localhost:8080/management/metrics, I am getting following response:
{"names":[
"cache.removals",
"http.server.requests",
"cache.evictions",
"cache.gets",
"process.start.time",
"cache.puts",
"http.server.requests.percentile",
"jvm.threads.states",
"jvm.memory.committed",
"jdbc.connections.active",
"jvm.gc.memory.promoted",
"jvm.memory.max",
"jvm.gc.pause.percentile",
"jvm.gc.max.data.size",
"jvm.gc.pause",
"jdbc.connections.max",
"jdbc.connections.min",
"system.cpu.count",
"logback.events",
"jvm.memory.used",
"jvm.threads.daemon",
"jvm.buffer.memory.used",
"system.cpu.usage",
"jvm.gc.memory.allocated",
"jdbc.connections.idle",
"jvm.threads.live",
"jvm.threads.peak",
"process.uptime",
"process.cpu.usage",
"jvm.classes.loaded",
"jvm.classes.unloaded",
"jvm.gc.live.data.size",
"jvm.buffer.count",
"jvm.buffer.total.capacity"]}
While I am expecting response like this:
I also tried to hit http://localhost:9999/management/jhimetrics, here I got 404 error.
Anyone encountered similar problem or any has solution? Please help.

how to minimize the memory footprint for a jhipster microservice environment?

After to create a basic microservice environment:
registry: jhipster-registry
User accounting and authorizing: jhipster-uaa
gateway: jhipster-gateway
microservice: jhipster-microservice
I run out of memory while I have set the environment variable:
JAVA_OPTS='-Xmx512m'
and my computer own 8Go (2Go used by the system)
jhipster-registry is launch through ./mvnw
jhipster-{uaa, gateway, microservice, foo} is launch through ./gradlew
Thanks for your help
Note: below the jh file used to generate those applications
# documentation https://www.jhipster.tech/jdl/
application {
config {
baseName uaa,
packageName fr.org.foo.uaa,
applicationType uaa,
serverPort 9999,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
cacheProvider hazelcast,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
testFrameworks [gatling,cucumber],
skipClient true
}
entities Workflow, Task, Command
}
application {
config {
baseName gateway,
packageName fr.org.foo.gateway,
applicationType gateway,
serverPort 8080,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
uaaBaseName "uaa",
cacheProvider hazelcast,
websocket spring-websocket,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
clientFramework react,
testFrameworks [gatling,cucumber,protractor],
jhiPrefix jhi
}
entities Workflow, Task, Command
}
application {
config {
baseName foo,
packageName fr.org.foo.foo,
applicationType microservice,
serverPort 8081,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
uaaBaseName "uaa",
cacheProvider hazelcast,
websocket spring-websocket,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
testFrameworks [gatling,cucumber],
jhiPrefix jhi
}
entities Workflow, Task, Command
}
entity Workflow {
id Long required,
name String required minlength(3),
description String
}
entity Task {
id Long required,
name String required minlength(3),
type TaskType required,
description String
}
# http://www.workflowpatterns.com/patterns/
enum TaskType {
Sequence,
Split,
Synchronization,
ExclusiveChoice,
SimpleMerge
}
entity Command {
id Long required,
command String required minlength(3),
parameters String,
version String required
}
relationship OneToMany {
Workflow{task} to Task,
Task{command} to Command
}
relationship ManyToOne {
Task{previous} to Task
Task{next} to Task
}
microservice Workflow, Task, Command with foo
Are you sure that JAVA_OPTS is used by mvnw or gradlew?
Personally, I set the JVM args in the pom.xml on the spring-boot-maven-plugin configuration:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
...
<configuration>
<executable>true</executable>
<fork>true</fork>
<mainClass>${start-class}</mainClass>
<jvmArguments>-Xms64m -Xmx128m</jvmArguments>
</configuration>
</plugin>
There is a similar setting for gradle
bootRun {
jvmArgs = ["-Xms64m", "-Xmx128m"]
}

Resources