Skip to content

Commit

Permalink
Merge branch 'mainline' into fix/monorepo-py-venv
Browse files Browse the repository at this point in the history
  • Loading branch information
cogwirrel authored Oct 5, 2023
2 parents 1ba8def + 917a5db commit 28edd36
Show file tree
Hide file tree
Showing 8 changed files with 14,875 additions and 10 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/aws-arch-pricing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ jobs:
pnpm projen post-compile
pnpm jest --updateSnapshot
pnpm projen package
- id: create_patch
name: Find mutations
- id: mutation_check
name: Find Mutations
# ignore diff if only the pricing manifest json was modified
run: |-
git add .
git diff --staged --name-only --exit-code -- ':!packages/aws-arch/static/aws-pricing-manifest.json' || echo "::set-output name=has_mutations::true"
- if: steps.mutation_check.outputs.has_mutations
id: create_patch
name: Create Patch
run: |-
git diff --staged --patch --exit-code > .repo.patch || echo "::set-output name=patch_created::true"
- if: steps.create_patch.outputs.patch_created
name: Upload patch
Expand Down
2 changes: 1 addition & 1 deletion docs/content/getting_started/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Now that the new dependency is installed, we can perform the following modificat
-
-const monorepo = new NxMonorepoProject({
+import { CloudscapeReactTsWebsiteProject } from "@aws/pdk/cloudscape-react-ts-website";
+import { MonorepoTsProject } from "@aws/pdk/nx-monorepo";
+import { MonorepoTsProject } from "@aws/pdk/monorepo";
+import {
+ DocumentationFormat,
+ Language,
Expand Down
9 changes: 4 additions & 5 deletions packages/aws-arch/scripts/aws-arch/fetch-pricing-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************************************************** */
import * as path from 'path';
import * as util from 'util';
import * as stream from 'stream';
import * as fs from 'fs-extra';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import fetch from 'node-fetch';

const URL = 'https://d1qsjq9pzbk1k6.cloudfront.net/manifest/en_US.json';
Expand All @@ -31,6 +29,7 @@ const FILEPATH = path.join(__dirname, '..', '..', 'static', 'aws-pricing-manifes
console.debug(response);
throw new Error(`Failed to download pricing manifest: ${response.statusText} - ${response.statusText}`);
}
await util.promisify(stream.pipeline)(response.body, fs.createWriteStream(FILEPATH));
const jsonData = await response.json();
await fs.writeFile(FILEPATH, JSON.stringify(jsonData, null, 2));
console.info('Done - pricing manifest fetched')
})();
14,726 changes: 14,725 additions & 1 deletion packages/aws-arch/static/aws-pricing-manifest.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import SwaggerParser from "@apidevtools/swagger-parser";
import { writeFile } from "projen/lib/util";
import { parse } from "ts-command-line-args";
import * as path from 'path';
import * as _ from "lodash";
import fs from "fs";
import type { OpenAPIV3 } from "openapi-types";

// Smithy HTTP trait is used to map Smithy operations to their location in the spec
const SMITHY_HTTP_TRAIT_ID = "smithy.api#http";
Expand Down Expand Up @@ -49,6 +51,7 @@ interface Arguments {
readonly outputPath: string;
}


void (async () => {
const args = parse<Arguments>({
specPath: { type: String, alias: "s" },
Expand Down Expand Up @@ -101,8 +104,16 @@ void (async () => {

const invalidRequestParameters: InvalidRequestParameter[] = [];

// Dereference a clone of the spec to test parameters
const dereferencedSpec = await SwaggerParser.dereference(JSON.parse(JSON.stringify(spec)), {
dereference: {
// Circular references are valid, we just ignore them for the purpose of validation
circular: "ignore",
},
});

// Validate the request parameters
Object.entries(spec.paths || {}).forEach(([p, pathOp]: [string, any]) => {
Object.entries(dereferencedSpec.paths || {}).forEach(([p, pathOp]: [string, any]) => {
Object.entries(pathOp ?? {}).forEach(([method, operation]: [string, any]) => {
(operation?.parameters ?? []).forEach((parameter: any) => {
// Check if the parameter is an allowed type
Expand Down
39 changes: 39 additions & 0 deletions packages/type-safe-api/test/resources/specs/parameter-refs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
openapi: 3.0.3
info:
version: 1.0.0
title: Example API
paths:
/hello:
get:
operationId: sayHello
x-handler:
language: typescript
parameters:
- $ref: '#/components/parameters/HelloId'
responses:
'200':
description: Successful response
content:
'application/json':
schema:
$ref: '#/components/schemas/HelloResponse'
components:
parameters:
HelloId:
in: query
name: id
schema:
$ref: '#/components/schemas/HelloId'
required: false
schemas:
HelloId:
type: string
HelloResponse:
type: object
properties:
id:
$ref: '#/components/schemas/HelloId'
message:
$ref: '#/components/schemas/HelloResponse'
required:
- id

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 @@ -58,4 +58,20 @@ describe("Parse OpenAPI Spec Script Unit Tests", () => {
);
});
});

it("Permits parameter references (and circular references)", () => {
expect(
withTmpDirSnapshot(os.tmpdir(), (tmpDir) => {
const specPath = "../../resources/specs/parameter-refs.yaml";
const outputPath = path.join(
path.relative(path.resolve(__dirname), tmpDir),
".api.json"
);
const command = `../../../scripts/type-safe-api/parser/parse-openapi-spec --spec-path ${specPath} --output-path ${outputPath}`;
exec(command, {
cwd: path.resolve(__dirname),
});
})
).toMatchSnapshot();
});
});

0 comments on commit 28edd36

Please sign in to comment.