mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
fix: replace spaces in components prefixes with underscores (#1455)
This commit is contained in:
5
.changeset/yellow-eels-divide.md
Normal file
5
.changeset/yellow-eels-divide.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@redocly/cli": patch
|
||||
---
|
||||
|
||||
Added inflection to the `join` command so that `--prefix-components-with-info-prop` replaces spaces with underscores to create less confusing $refs.
|
||||
@@ -40,10 +40,10 @@ paths:
|
||||
'200':
|
||||
description: example description
|
||||
security:
|
||||
- Foo Example OpenAPI 3 definition foo._scheme1: []
|
||||
Foo Example OpenAPI 3 definition foo._scheme2: []
|
||||
Foo Example OpenAPI 3 definition foo._scheme3: []
|
||||
Foo Example OpenAPI 3 definition foo._scheme4: []
|
||||
- Foo_Example_OpenAPI_3_definition_foo._scheme1: []
|
||||
Foo_Example_OpenAPI_3_definition_foo._scheme2: []
|
||||
Foo_Example_OpenAPI_3_definition_foo._scheme3: []
|
||||
Foo_Example_OpenAPI_3_definition_foo._scheme4: []
|
||||
tags:
|
||||
- foo_other
|
||||
/pets/{petId}:
|
||||
@@ -54,28 +54,28 @@ paths:
|
||||
'201':
|
||||
description: example description
|
||||
security:
|
||||
- Bar Example OpenAPI 3 definition._scheme1: []
|
||||
Bar Example OpenAPI 3 definition._scheme2: []
|
||||
- Bar Example OpenAPI 3 definition._scheme3: []
|
||||
Bar Example OpenAPI 3 definition._scheme4: []
|
||||
- Bar_Example_OpenAPI_3_definition._scheme1: []
|
||||
Bar_Example_OpenAPI_3_definition._scheme2: []
|
||||
- Bar_Example_OpenAPI_3_definition._scheme3: []
|
||||
Bar_Example_OpenAPI_3_definition._scheme4: []
|
||||
tags:
|
||||
- bar_other
|
||||
components:
|
||||
schemas:
|
||||
Foo Example OpenAPI 3 definition foo._some-property:
|
||||
Foo_Example_OpenAPI_3_definition_foo._some-property:
|
||||
description: foo description
|
||||
type: string
|
||||
Foo Example OpenAPI 3 definition foo._another-property:
|
||||
Foo_Example_OpenAPI_3_definition_foo._another-property:
|
||||
description: description
|
||||
$ref: '#/components/schemas/Foo Example OpenAPI 3 definition foo._some-property'
|
||||
Bar Example OpenAPI 3 definition._some-property:
|
||||
$ref: '#/components/schemas/Foo_Example_OpenAPI_3_definition_foo._some-property'
|
||||
Bar_Example_OpenAPI_3_definition._some-property:
|
||||
description: bar description
|
||||
type: string
|
||||
nullable: true
|
||||
default: null
|
||||
Bar Example OpenAPI 3 definition._another-property:
|
||||
Bar_Example_OpenAPI_3_definition._another-property:
|
||||
description: description
|
||||
$ref: '#/components/schemas/Bar Example OpenAPI 3 definition._some-property'
|
||||
$ref: '#/components/schemas/Bar_Example_OpenAPI_3_definition._some-property'
|
||||
x-tagGroups:
|
||||
- name: Foo Example OpenAPI 3 definition foo.
|
||||
tags:
|
||||
|
||||
@@ -13,15 +13,15 @@ info:
|
||||
servers:
|
||||
- url: https://redocly.com/v1
|
||||
tags:
|
||||
- name: Foo Example OpenAPI 3 definition with foo title._Pet
|
||||
- name: Foo_Example_OpenAPI_3_definition_with_foo_title._Pet
|
||||
description: Pet Discription
|
||||
x-displayName: Pet
|
||||
- name: Foo Example OpenAPI 3 definition with foo title._other
|
||||
- name: Foo_Example_OpenAPI_3_definition_with_foo_title._other
|
||||
x-displayName: other
|
||||
- name: Bar Example OpenAPI 3 definition._Pet
|
||||
- name: Bar_Example_OpenAPI_3_definition._Pet
|
||||
description: Pet Discription
|
||||
x-displayName: Pet
|
||||
- name: Bar Example OpenAPI 3 definition._other
|
||||
- name: Bar_Example_OpenAPI_3_definition._other
|
||||
x-displayName: other
|
||||
paths:
|
||||
/pets:
|
||||
@@ -40,7 +40,7 @@ paths:
|
||||
'200':
|
||||
description: example description
|
||||
tags:
|
||||
- Foo Example OpenAPI 3 definition with foo title._other
|
||||
- Foo_Example_OpenAPI_3_definition_with_foo_title._other
|
||||
/pets/{petId}:
|
||||
post:
|
||||
summary: summary example
|
||||
@@ -49,17 +49,17 @@ paths:
|
||||
'201':
|
||||
description: example description
|
||||
tags:
|
||||
- Bar Example OpenAPI 3 definition._other
|
||||
- Bar_Example_OpenAPI_3_definition._other
|
||||
components: {}
|
||||
x-tagGroups:
|
||||
- name: Foo Example OpenAPI 3 definition with foo title.
|
||||
tags:
|
||||
- Foo Example OpenAPI 3 definition with foo title._Pet
|
||||
- Foo Example OpenAPI 3 definition with foo title._other
|
||||
- Foo_Example_OpenAPI_3_definition_with_foo_title._Pet
|
||||
- Foo_Example_OpenAPI_3_definition_with_foo_title._other
|
||||
- name: Bar Example OpenAPI 3 definition.
|
||||
tags:
|
||||
- Bar Example OpenAPI 3 definition._Pet
|
||||
- Bar Example OpenAPI 3 definition._other
|
||||
- Bar_Example_OpenAPI_3_definition._Pet
|
||||
- Bar_Example_OpenAPI_3_definition._other
|
||||
|
||||
openapi.yaml: join processed in <test>ms
|
||||
|
||||
|
||||
@@ -259,12 +259,12 @@ describe('handleJoin', () => {
|
||||
},
|
||||
components: {
|
||||
schemas: {
|
||||
'Third API_SchemaWithNull': {
|
||||
Third_API_SchemaWithNull: {
|
||||
type: 'string',
|
||||
default: null,
|
||||
nullable: true,
|
||||
},
|
||||
'Third API_SchemaWithRef': {
|
||||
Third_API_SchemaWithRef: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
schemaType: {
|
||||
@@ -272,21 +272,21 @@ describe('handleJoin', () => {
|
||||
enum: ['foo'],
|
||||
},
|
||||
foo: {
|
||||
$ref: '#/components/schemas/Third API_SchemaWithNull',
|
||||
$ref: '#/components/schemas/Third_API_SchemaWithNull',
|
||||
},
|
||||
},
|
||||
},
|
||||
'Third API_SchemaWithDiscriminator': {
|
||||
Third_API_SchemaWithDiscriminator: {
|
||||
discriminator: {
|
||||
propertyName: 'schemaType',
|
||||
mapping: {
|
||||
foo: '#/components/schemas/Third API_SchemaWithRef',
|
||||
bar: '#/components/schemas/Third API_SchemaWithNull',
|
||||
foo: '#/components/schemas/Third_API_SchemaWithRef',
|
||||
bar: '#/components/schemas/Third_API_SchemaWithNull',
|
||||
},
|
||||
},
|
||||
oneOf: [
|
||||
{
|
||||
$ref: '#/components/schemas/Third API_SchemaWithRef',
|
||||
$ref: '#/components/schemas/Third_API_SchemaWithRef',
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
|
||||
@@ -784,7 +784,7 @@ function getInfoPrefix(info: any, prefixArg: string | undefined, type: string) {
|
||||
`prefix-${type}-with-info-prop`
|
||||
)} argument value length should not exceed 50 characters. \n\n`
|
||||
);
|
||||
return info[prefixArg];
|
||||
return info[prefixArg].replaceAll(/\s/g, '_');
|
||||
}
|
||||
|
||||
async function validateApi(
|
||||
|
||||
Reference in New Issue
Block a user