Skip to content

Commit

Permalink
feat(type-safe-api): remove dependency on openapi generator and java …
Browse files Browse the repository at this point in the history
…for all code/docs generation (#870)

Remove the dependency on openapi generator and java for code generation for all Type Safe API
projects.

BREAKING CHANGE: Remove the HTML2 documentation format. Please use HTML_REDOC for HTML
documentation.
  • Loading branch information
cogwirrel authored Oct 22, 2024
1 parent 0b8fe10 commit 9bda068
Show file tree
Hide file tree
Showing 49 changed files with 1,690 additions and 13,472 deletions.
6 changes: 0 additions & 6 deletions .projen/tasks.json

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

6 changes: 0 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ RUN dnf -y install graphviz
RUN dnf -y install rubygems ruby
RUN gem install license_finder

# Open API Generator
RUN mkdir -p ~/.open-api-generator-cli
RUN curl https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar -o ~/.open-api-generator-cli/6.3.0.jar
RUN curl https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.1.0/openapi-generator-cli-7.1.0.jar -o ~/.open-api-generator-cli/7.1.0.jar
RUN curl https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.6.0/openapi-generator-cli-6.6.0.jar -o ~/.open-api-generator-cli/6.6.0.jar

# =====================================

# Entrypoint script
Expand Down
8 changes: 6 additions & 2 deletions docs/content/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,19 @@ git config --global user.email "[email protected]"
git config --global user.name "username"
```

### JDK + Maven (If using Type Safe API)
### JDK + Maven (If using Type Safe API with Smithy)

The Type Safe API requires JDK >= 11 and Maven >= 3.8 in order to perform the required code generation.
If you intend to use Type Safe API with [Smithy](https://smithy.io/2.0/), JDK >= 11 and Maven >= 3.8 are required in order to build and validate the Smithy model.

To install these, follow the below links:

- JDK: We recommend installing any Coretto version >= 11 https://docs.aws.amazon.com/corretto/
- Maven: You can any version of Maven >= 3.8: https://maven.apache.org/install.html

!!!note

If you are using another modelling language (for example OpenAPI), these are not required.

### Language specific

Other prerequisites depend on the language in which you develop AWS PDK projects and are as follows.
Expand Down
8 changes: 4 additions & 4 deletions docs/content/getting_started/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const api = new TypeSafeApiProject({
libraries: [Library.TYPESCRIPT_REACT_QUERY_HOOKS],
},
documentation: {
formats: [DocumentationFormat.HTML2],
formats: [DocumentationFormat.HTML_REDOC],
},
});

Expand All @@ -101,7 +101,7 @@ new AwsCdkTypeScriptApp({
prettier: true,
name: "infra-main",
deps: [
+ "@aws/pdk",
+ "@aws/pdk",
"@aws-prototyping-sdk/static-website",
"@aws-prototyping-sdk/identity",
"@aws-prototyping-sdk/pipeline",
Expand Down Expand Up @@ -183,7 +183,7 @@ const graph = new CdkGraph(app, {
- // do something
- },
+ { store: Filters.pruneCustomResources() },
+ {
+ {
+ store: (store) => {
+ // do something
+ }
Expand All @@ -209,7 +209,7 @@ The `PDKPipelineTsProject` has been removed as it did not provide an adequate le
+import { AwsCdkTypeScriptApp } from "projen/lib/awscdk"

-const pipelineProject = new PDKPipelineTsProject({
+const pipelineProject = new AwsCdkTypeScriptApp({
+const pipelineProject = new AwsCdkTypeScriptApp({
parent: monorepo,
outdir: "packages/infra",
defaultReleaseBranch: "mainline",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe("CloudscapeReactTsWebsiteProject Unit Tests", () => {
},
documentation: {
formats: [
DocumentationFormat.HTML2,
DocumentationFormat.MARKDOWN,
DocumentationFormat.PLANTUML,
DocumentationFormat.HTML_REDOC,
Expand Down Expand Up @@ -93,7 +92,6 @@ describe("CloudscapeReactTsWebsiteProject Unit Tests", () => {
},
documentation: {
formats: [
DocumentationFormat.HTML2,
DocumentationFormat.MARKDOWN,
DocumentationFormat.PLANTUML,
DocumentationFormat.HTML_REDOC,
Expand Down
7 changes: 1 addition & 6 deletions packages/pdk/package.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ The `TypeSafeApiProject` projen project creates a REST API, and produces the fol
|_ python
|_ java
|_ documentation/ - generated documentation in the formats you specified
|_ html2
|_ html_redoc
|_ plantuml
|_ markdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,82 +227,6 @@ Make sure you do not deploy your CDK stack with `type-safe-api-local` set to `tr

Note also that your API business logic may include operations which do not work locally, or may interact with real AWS resources depending on the AWS credentials you start your local development server with.

### How do I customise OpenAPI Generator CLI?

[OpenAPI Generator CLI](https://github.com/OpenAPITools/openapi-generator-cli) is used to generate the infrastructure, runtime and library projects. You can customise some of its properties for specific projects if you like. Note that changing the `version` may cause generated code to be broken, since it's written assuming the default version.

For example, to customise the maven repository used to pull the OpenAPI Generator jar, you can configure the `TypeSafeApiProject` as follows:

=== "TS"

```ts
const openApiGeneratorCliConfig: OpenApiGeneratorCliConfig = {
repository: {
downloadUrl:
"https://my.custom.maven.repo/maven2/${groupId}/${artifactId}/${versionName}/${artifactId}-${versionName}.jar",
},
};

const project = new TypeSafeApiProject({
infrastructure: {
language: Language.TYPESCRIPT,
options: {
typescript: {
openApiGeneratorCliConfig,
},
},
},
// Repeat for handlers, runtime, documentation, library
...
});
```

=== "JAVA"

```java
OpenApiGeneratorCliConfig openApiGeneratorCliConfig = OpenApiGeneratorCliConfig.builder()
.repository(OpenApiGeneratorCliConfigRepository.builder()
.downloadUrl("https://my.custom.maven.repo/maven2/${groupId}/${artifactId}/${versionName}/${artifactId}-${versionName}.jar")
.build())
.build();

TypeSafeApiProject project = new TypeSafeApiProject(TypeSafeApiProjectOptions.builder()
.infrastructure(InfrastructureConfiguration.builder()
.language(Language.JAVA)
.options(GeneratedInfrastructureCodeOptions.builder()
.java(GeneratedJavaInfrastructureOptions.builder()
.openApiGeneratorCliConfig(openApiGeneratorCliConfig)
.build())
.build())
.build())
// Repeat for handlers, runtime, documentation, library
...
.build();
```

=== "PYTHON"

```python
openapi_generator_cli_config = OpenApiGeneratorCliConfig(
repository=OpenApiGeneratorCliConfigRepository(
download_url="https://my.custom.maven.repo/maven2/${groupId}/${artifactId}/${versionName}/${artifactId}-${versionName}.jar"
)
)

project = TypeSafeApiProject(
infrastructure=InfrastructureConfiguration(
language=Language.PYTHON,
options=GeneratedInfrastructureCodeOptions(
python=GeneratedPythonInfrastructureOptions(
open_api_generator_cli_config=open_api_generator_cli_config
)
)
),
# Repeat for handlers, runtime, documentation, library
...
)
```

### Can I implement my API operations with something other than Lambda, like ECS?

Yes. You can write a custom integration and integrate with any of the services supported by API Gateway. See the [Integrations](../../developer_guides/type-safe-api/integrations.md) section for more information.
Expand Down
7 changes: 1 addition & 6 deletions packages/type-safe-api/package.json

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

18 changes: 0 additions & 18 deletions packages/type-safe-api/scripts/type-safe-api/common/.pnpmfile

This file was deleted.

122 changes: 0 additions & 122 deletions packages/type-safe-api/scripts/type-safe-api/common/common.sh

This file was deleted.

Loading

0 comments on commit 9bda068

Please sign in to comment.