Comments (6)
@mrlubos just to maintain a well known name for the client, because our apps then do:
import { swaggerClient } from './swaggerClient'
It doesn't matter if it's called swaggerClient
, so long as it's deterministic
from openapi-ts.
So looking at the templating:
{{#if @root.useOptions}}
import { mergeOpenApiConfig, OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
import type { TApiResponse, TConfig, TResult } from '../core/types';
{{else}}
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
{{/if}}
We're using useOptions: true
.
from openapi-ts.
@Stono oops, sorry for that. Can you share the full command you're using to generate the client? It seems you're not using exportCore
, right?
from openapi-ts.
Hey,
I am using exportCore
.
What we're doing is a bit interesting btw, we dont use the cli - instead i invoke it programatically:
const openApi = require('@nicolas-chaulet/openapi-typescript-codegen/dist')
await openApi.generate({
input: tmpLocation,
output: destinationLib,
httpClient: 'fetch',
exportCore: true,
exportServices: true,
exportModels: true,
exportSchemas: false,
postfixServices: '',
postfixModels: '',
clientName: 'swaggerClient',
useOptions: true,
useUnionTypes: true
})
Core does look to be exported as i'd expect:
![Screenshot 2024-03-04 at 12 11 32](https://private-user-images.githubusercontent.com/1486729/309748489-a830bc8b-afc5-4e54-937e-da3b4093fa15.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTY0MzAyMzEsIm5iZiI6MTcxNjQyOTkzMSwicGF0aCI6Ii8xNDg2NzI5LzMwOTc0ODQ4OS1hODMwYmM4Yi1hZmM1LTRlNTQtOTM3ZS1kYTNiNDA5M2ZhMTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDUyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA1MjNUMDIwNTMxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGQxZjRjZjAyYzM3OWQ4ZGQ1MzdhZTIzZDQ4NTNiZWRkMWJiNzAxODNhZTRkNzljOTEzYzc4NWYwYjVhY2Y4YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.3k_SZYHl4HBeUIzV_CzlCkSX_SxR4jP53vVyGpv-cNE)
The types just aren't being imported in the generated service
from openapi-ts.
@Stono got it, thanks! I will fix it today if you can give me one more pointer. I see this is because you use clientName
, I didn't implement it with that field. Can you explain what's that field used for on your end? Do you implement anything custom?
from openapi-ts.
@Stono this is fixed in v0.27.19 🚀 Thanks for catching it!
I want to ask, however, more about the use of clientName
. Personally I don't use it, so it may help me prevent similar mistakes in the future. clientName
will generate a file in client/swaggerClient.ts
– do you use this module? If so, how? I am still not clear what you get from this flag that you couldn't get by not using it and setting output
to src/swaggerClient
which would then be used elsewhere as import { Services } from 'swaggerClient'
?
from openapi-ts.
Related Issues (20)
- Enums clash HOT 2
- The generated Service layer code contains Chinese characters HOT 11
- Use exported enums in type fields HOT 3
- It does not pickup typescript in monorepo environment w/ pnpm HOT 3
- Content type headers not passed onto request HOT 4
- Rename conflicting TypeScript identifiers
- DeprecationWarning: fs.Stats constructor is deprecated HOT 3
- export eslint.rules for external usage HOT 3
- Got client HOT 17
- Non-global clients/configs HOT 6
- Export services as module instead of class to enable tree shaking. HOT 10
- Unused @ts-expect-error comment HOT 17
- Support for exactOptionalPropertyTypes in tsconfig.json HOT 3
- Validate response against openapi schema HOT 1
- Standalone package for your client HOT 2
- [question] How does this package compare to `openapi-typescript`? HOT 2
- can't generate a node16 moduleResolution compatible package HOT 8
- Improve support for `Accept` and `Content-Type` headers
- Newly exported `DefaultService` does not exist HOT 14
- Export `FetchClient` interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-ts.