-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): improve openapi code generation for naming and typing
- validated against openapi specs from https://www.berlin-group.org/psd2-access-to-bank-accounts
- Loading branch information
1 parent
35f719c
commit 1877727
Showing
6 changed files
with
85 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/cli | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
const expect = require('@loopback/testlab').expect; | ||
const utils = require('../../../generators/openapi/utils'); | ||
|
||
describe('openapi utils', () => { | ||
it('escapes keywords for an identifier', () => { | ||
expect(utils.escapeIdentifier('for')).to.eql('_for'); | ||
}); | ||
|
||
it('escapes illegal chars for an identifier', () => { | ||
expect(utils.escapeIdentifier('foo bar')).to.eql('fooBar'); | ||
expect(utils.escapeIdentifier('foo-bar')).to.eql('fooBar'); | ||
expect(utils.escapeIdentifier('foo.bar')).to.eql('fooBar'); | ||
}); | ||
|
||
it('does not escape legal chars for an identifier', () => { | ||
expect(utils.escapeIdentifier('foobar')).to.eql('foobar'); | ||
expect(utils.escapeIdentifier('fooBar')).to.eql('fooBar'); | ||
expect(utils.escapeIdentifier('Foobar')).to.eql('Foobar'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters