Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ivank committed Feb 24, 2024
1 parent 437af59 commit 7eb232b
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.

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
@@ -1,8 +1,8 @@
import { HttpService, init, jsonOk } from '@laminarjs/laminar';
import { openApiTyped } from './__generated__/convertion.yaml';
import { openApiTyped } from './__generated__/conversion.yaml';
import { join } from 'path';

const api = join(__dirname, 'convertion.yaml');
const api = join(__dirname, 'conversion.yaml');

const main = async () => {
const listener = await openApiTyped({
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"build:test:pullrequest": "yarn laminar json-schema --file test/json-schema/pullrequest.yaml --output test/json-schema/__generated__/pullrequest.ts",
"build:examples:api": "yarn laminar api --file examples/api.yaml --output examples/__generated__/api.yaml.ts",
"build:examples:axios": "yarn laminar axios --file examples/axios.yaml --output examples/__generated__/axios.yaml.ts",
"build:examples:convertion": "yarn laminar api --file examples/convertion.yaml --output examples/__generated__/convertion.yaml.ts",
"build:examples:conversion": "yarn laminar api --file examples/conversion.yaml --output examples/__generated__/conversion.yaml.ts",
"build:examples:petstore": "yarn laminar axios --file examples/petstore.json --output examples/__generated__/petstore.json.ts",
"build:examples": "yarn build:examples:api && yarn build:examples:axios && yarn build:examples:petstore && yarn build:examples:convertion",
"build:examples": "yarn build:examples:api && yarn build:examples:axios && yarn build:examples:petstore && yarn build:examples:conversion",
"build:test": "yarn build:test:petstore && yarn build:test:split && yarn build:test:statements && yarn build:test:loss && yarn build:test:axios && yarn build:test:axios-api && yarn build:test:pullrequest",
"pretest": "yarn build:examples && yarn build:test",
"build": "tsc --declaration",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Example files', () => {
{ text: 'ok', user: { email: 'me@example.com' } },
],
[
'examples/convertion.ts',
'examples/conversion.ts',
{
method: 'GET',
url: '/user',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/json-schema/pullrequest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ensureValid } from '@laminarjs/json-schema';
import { join } from 'path';

describe('Json Schema', () => {
it('Should use types from convertion function', async () => {
it('Should use types from conversion function', async () => {
const value = { id: 123, title: 'other' };

const result = await ensureValid<Type>({ schema: join(__dirname, 'pullrequest.yaml'), value });
Expand Down
6 changes: 3 additions & 3 deletions packages/laminar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,19 @@ const MySecurity = ({ headers }, { scopes }) => {

You can use [@laminarjs/cli](../lamina-cli) package to generate types.

### Json Type Convertion
### Json Type conversion

JSON and JS object are not _exactly_ the same, as you can [read to your horror at MDN docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description). Laminar tries to follow that spec, converting your JS objects into stuff that your json-schema can validate. For example Date objects are converted to iso strings and undefined fields are omitted from the object.

This works on type level too. The types generated from the OpenApi schema would match JS objects passed to the helper functions `jsonOk`, `jsonNotFound` etc.

> [examples/convertion.ts](https://github.com/ivank/laminar/tree/main/packages/laminar/examples/convertion.ts)
> [examples/conversion.ts](https://github.com/ivank/laminar/tree/main/packages/laminar/examples/conversion.ts)
```typescript
import { HttpService, jsonOk, openApi, init } from '@laminarjs/laminar';
import { join } from 'path';

const api = join(__dirname, 'convertion.yaml');
const api = join(__dirname, 'conversion.yaml');

const main = async () => {
const listener = await openApi({
Expand Down
2 changes: 1 addition & 1 deletion packages/laminar/examples/convertion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpService, jsonOk, openApi, init } from '@laminarjs/laminar';
import { join } from 'path';

const api = join(__dirname, 'convertion.yaml');
const api = join(__dirname, 'conversion.yaml');

const main = async () => {
const listener = await openApi({
Expand Down
2 changes: 1 addition & 1 deletion packages/laminar/test/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe('Example files', () => {
{},
],
[
'examples/convertion.ts',
'examples/conversion.ts',
{
method: 'GET',
url: '/user',
Expand Down

0 comments on commit 7eb232b

Please sign in to comment.