sofa-api 0.17.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -481,7 +481,7 @@ function resolveResponse({ schema, operation, opts, }) {
481
481
  }
482
482
  }
483
483
  function isInPath(url, param) {
484
- return url.includes(`:${param}`);
484
+ return url.includes(`:${param}`) || url.includes(`{${param}}`);
485
485
  }
486
486
  function getOperationFieldNode(schema, operation) {
487
487
  const selection = operation.selectionSet.selections[0];
@@ -559,10 +559,13 @@ function createRouter(sofa) {
559
559
  }
560
560
  const router = fets.createRouter({
561
561
  base: sofa.basePath,
562
+ components,
562
563
  title: sofa.title || 'SOFA API',
563
564
  description: sofa.description || 'Generated by SOFA',
564
565
  version: sofa.version || '0.0.0',
565
- components,
566
+ oasEndpoint: sofa.oasEndpoint,
567
+ swaggerUIEndpoint: sofa.swaggerUIEndpoint,
568
+ swaggerUIOpts: sofa.swaggerUIOpts,
566
569
  });
567
570
  const queryType = sofa.schema.getQueryType();
568
571
  const mutationType = sofa.schema.getMutationType();
package/index.mjs CHANGED
@@ -475,7 +475,7 @@ function resolveResponse({ schema, operation, opts, }) {
475
475
  }
476
476
  }
477
477
  function isInPath(url, param) {
478
- return url.includes(`:${param}`);
478
+ return url.includes(`:${param}`) || url.includes(`{${param}}`);
479
479
  }
480
480
  function getOperationFieldNode(schema, operation) {
481
481
  const selection = operation.selectionSet.selections[0];
@@ -553,10 +553,13 @@ function createRouter(sofa) {
553
553
  }
554
554
  const router = createRouter$1({
555
555
  base: sofa.basePath,
556
+ components,
556
557
  title: sofa.title || 'SOFA API',
557
558
  description: sofa.description || 'Generated by SOFA',
558
559
  version: sofa.version || '0.0.0',
559
- components,
560
+ oasEndpoint: sofa.oasEndpoint,
561
+ swaggerUIEndpoint: sofa.swaggerUIEndpoint,
562
+ swaggerUIOpts: sofa.swaggerUIOpts,
560
563
  });
561
564
  const queryType = sofa.schema.getQueryType();
562
565
  const mutationType = sofa.schema.getMutationType();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sofa-api",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Create REST APIs with GraphQL",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
package/sofa.d.ts CHANGED
@@ -2,6 +2,7 @@ import { GraphQLSchema, subscribe, execute } from 'graphql';
2
2
  import { Ignore, ContextFn, ContextValue } from './types';
3
3
  import { ErrorHandler } from './router';
4
4
  import { HTTPMethod, StatusCode } from 'fets/typings/typed-fetch';
5
+ import { SwaggerUIOpts } from 'fets/typings/plugins/openapi';
5
6
  export interface RouteConfig {
6
7
  method?: HTTPMethod;
7
8
  path?: string;
@@ -34,8 +35,11 @@ export interface SofaConfig {
34
35
  customScalars?: Record<string, any>;
35
36
  enumTypes?: Record<string, any>;
36
37
  title?: string;
37
- version?: string;
38
38
  description?: string;
39
+ version?: string;
40
+ oasEndpoint?: string | false;
41
+ swaggerUIEndpoint?: string | false;
42
+ swaggerUIOpts?: SwaggerUIOpts;
39
43
  }
40
44
  export interface Sofa {
41
45
  basePath: string;
@@ -51,8 +55,11 @@ export interface Sofa {
51
55
  customScalars: Record<string, any>;
52
56
  enumTypes: Record<string, any>;
53
57
  title?: string;
54
- version?: string;
55
58
  description?: string;
59
+ version?: string;
60
+ oasEndpoint?: string | false;
61
+ swaggerUIEndpoint?: string | false;
62
+ swaggerUIOpts?: SwaggerUIOpts;
56
63
  }
57
64
  export declare function createSofa(config: SofaConfig): Sofa;
58
65
  export declare function isContextFn(context: any): context is ContextFn;