Skip to content

Commit

Permalink
Release v1.1.8 (#12)
Browse files Browse the repository at this point in the history
* Ignore the stats.json

* 1.1.6

* Remove postinstall scripts

* 1.1.7

* README fix

* Updated README

* Fix the text case default typo

* 1.1.8
  • Loading branch information
cchandurkar authored Feb 21, 2021
1 parent 4361aea commit 535cd10
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
A library to convert complex JSON Schema to [Scala Case Classes](https://docs.scala-lang.org/tour/case-classes.html). Supports both NodeJs and Browser environments.
[Try Online Editor](https://cchandurkar.github.io/case-class-generator/).

#### Features
![Build Status](https://github.com/cchandurkar/json-schema-to-case-class/actions/workflows/build-and-deploy.yml/badge.svg?branch=main)
[![npm version](https://badge.fury.io/js/json-schema-to-case-class.svg)](https://badge.fury.io/js/json-schema-to-case-class)
[![License](https://img.shields.io/npm/l/json-schema-to-case-class.svg)](LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![PRs Welcome](https://img.shields.io/badge/$-support-green.svg?style=flat-square)](https://github.com/sponsors/cchandurkar)


### Features
1. Resolve local as well as remote schema references.
2. Handle nested JSON schema objects.
3. Can wrap optional fields in `Option[]`.
Expand All @@ -11,10 +18,12 @@ A library to convert complex JSON Schema to [Scala Case Classes](https://docs.sc
6. Can default to provided generic type. (default `Any`)


#### Installing
### Installing
```npm install --save json-schema-to-case-class```

#### Usage
[![NPM](https://nodei.co/npm/json-schema-to-case-class.png?compact=true)](https://nodei.co/npm/json-schema-to-case-class/)

### Usage

For NodeJs (TypeScript):
```typescript
Expand Down Expand Up @@ -47,7 +56,7 @@ For browser: If you are using the prebuild bundle, it has all the APIs under `Sc
SchemaConverter.convert( mySchema, config )
```

#### Configuration
### Configuration

It is optional to pass configuration object. Every configuration setting is optional as well. When not passed, default kicks-in. `IConfig`:

Expand All @@ -62,21 +71,21 @@ It is optional to pass configuration object. Every configuration setting is opti
| parseRefs | boolean | Whether to resolve the local or remote schema references ($ref). | true |
| generateComments | boolean | Whether to generate scaladoc-like comments for the case class generated. | false |

#### Browser Support
### Browser Support
This library supports recent versions of every major web browsers. Refer to the browserified build `dist/js2cc.min.js` that you can directly use in `<script />` tag of HTML page. It already bundles all the required polyfills.

#### Limitations
### Limitations
As of now, it does not support a few latest JSON Schema features such as `allOf`/ `anyOf`/ `oneOf`.

#### Contributing
### Contributing
All contributions, enhancements, and bug-fixes are welcome. Open an issue or create a pull request.

#### Short-term Goals
##### Short-term Goals
1. Handle `allOf`/ `anyOf`/ `oneOf`.
2. Add support for converting YAML.
3. Update online editor to add more examples to choose from.

###### Building locally
##### Building locally
1. Clone the repo <br />
`https://github.com/cchandurkar/json-schema-to-case-class.git`

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-schema-to-case-class",
"version": "1.1.7",
"version": "1.1.8",
"description": "A library that converts JSON Schema to Scala Case Classes",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ const resolveRefs = async (schema: any): Promise<IResolveRefsResult> => {
const stripSchemaObject = (schemaObject: any, currentDepth: number, entityTitle: string, config: IConfigResolved) : ICaseClassDef => {

// Text cases
const classNameTextCase = get(supportedTextCases, config.classNameTextCase, (x: string|null) => x + 'LoL');
const classParamsTextCase = get(supportedTextCases, config.classParamsTextCase, (x: string|null) => x + 'LoL');
const classNameTextCase = get(supportedTextCases, config.classNameTextCase, (x: string|null) => x);
const classParamsTextCase = get(supportedTextCases, config.classParamsTextCase, (x: string|null) => x);

// Use schema object 'title' field to derive case class name.
// For nested properties, use the object 'key' as case class name.
Expand Down

0 comments on commit 535cd10

Please sign in to comment.