Skip to content

Commit

Permalink
Make 'id' required in example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrause committed May 25, 2024
1 parent 9f10422 commit 6054a2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ npx openapi-to-effect gen ./api.json ./output --spec=./spec.ts
### Example

```console
npx openapi-to-effect gen ./api.json ./output --spec=./spec.ts
npx openapi-to-effect gen ./example_api.json ./output --spec=./example_spec.ts
```

**api.json**
**example_api.json**

```json
{
Expand Down Expand Up @@ -98,21 +98,21 @@ npx openapi-to-effect gen ./api.json ./output --spec=./spec.ts
"default": []
}
},
"required": ["name", "last_logged_in", "role"]
"required": ["id", "name", "last_logged_in", "role"]
}
}
}
}
```

**spec.ts**
**example_spec.ts**

```ts
import { type GenerationSpec } from '../../src/generation/generationSpec.ts';


export default {
generationMethod: { method: 'bundled', bundleName: 'fixture0' },
generationMethod: { method: 'bundled', bundleName: 'example' },
hooks: {},
runtime: {},
modules: {
Expand All @@ -136,7 +136,7 @@ export default {
} satisfies GenerationSpec;
```

**Output**
**output/example.ts**

```ts
import { Schema as S } from '@effect/schema';
Expand Down Expand Up @@ -169,7 +169,7 @@ export type CategoryEncoded = S.Schema.Encoded<typeof Category>;
/* User */

export const User = S.Struct({
id: S.optional(S.UUID), // Unique ID
id: S.UUID, // Unique ID
name: S.String, // The user's full name.
last_logged_in: S.Date, // When the user last logged in.
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/fixture0_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"default": []
}
},
"required": ["name", "last_logged_in", "role"]
"required": ["id", "name", "last_logged_in", "role"]
}
}
}
Expand Down

0 comments on commit 6054a2b

Please sign in to comment.