Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace strings with schema type resolvers #1407

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2200bc3
Using lift instead of just switching which toXYZ is being called
blast-hardcheese Feb 19, 2022
b3fabdc
Renaming swagger to schema
blast-hardcheese Feb 16, 2022
50dd432
Eliminating unreachable code
blast-hardcheese Feb 16, 2022
16301bf
DefaultCharset is deprecated
blast-hardcheese Feb 20, 2022
27aec87
Threading through components
blast-hardcheese Feb 16, 2022
959d834
Adding dereference methods for following $refs through Components
blast-hardcheese Feb 16, 2022
dc2a0a8
Using schema subtypes for default extraction instead of string compar…
blast-hardcheese Feb 14, 2022
4c1a303
Using parameter schema exclusively instead of getType/getFormat
blast-hardcheese Feb 14, 2022
5cca673
Deduplicate call to getBodyParameterSchema
blast-hardcheese Feb 16, 2022
209863b
Using Schema[_] for determineTypeName
blast-hardcheese Feb 14, 2022
eff310c
Threading components through ProtocolGenerator
blast-hardcheese Feb 20, 2022
b4c2673
Adding Vector type matcher to akka-http server generator
blast-hardcheese Feb 20, 2022
5cee0d1
Using lift instead of hardcoding toList
blast-hardcheese Feb 20, 2022
255fa1e
Creating and threading through reified raw types for core.Resolved
blast-hardcheese Feb 19, 2022
bc93a48
Hamfisted attempt at just shoving ReifiedRawType in there
blast-hardcheese Feb 19, 2022
8d495ad
Inline transform call to avoid random val res = ...
blast-hardcheese Feb 19, 2022
01f3c9e
Correcting previously incorrect types in tests
blast-hardcheese Feb 19, 2022
a1e1b02
Adding support in for customArrayTypeName
blast-hardcheese Feb 19, 2022
2bcfb99
Rewriting tests to use Vector
blast-hardcheese Feb 20, 2022
2d80e33
Ensuring samples get cleaned as well
blast-hardcheese May 22, 2022
5d87508
Adding a note about the Iterator -> Vector change
blast-hardcheese May 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: sbt ++${{ matrix.scala.version }} clean guardrail/clean checkFormatting coverage guardrail/test coverageAggregate versionPolicyCheck microsite/compile
run: sbt ++${{ matrix.scala.version }} clean samples/clean checkFormatting coverage guardrail/test coverageAggregate versionPolicyCheck microsite/compile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GUARDRAIL_CI: true
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
restore-keys: |
${{ runner.os }}-scala-${{ matrix.scala.version }}-
- name: Run tests
run: sbt ++${{ matrix.scala.version }} clean guardrail/clean coverage "runExample java ${{ matrix.framework.framework }}" ${{ matrix.framework.project }}/test coverageAggregate
run: sbt ++${{ matrix.scala.version }} clean samples/clean coverage "runExample java ${{ matrix.framework.framework }}" ${{ matrix.framework.project }}/test coverageAggregate
- uses: codecov/codecov-action@v1
with:
file: ./target/scala-${{ matrix.scala.bincompat }}/scoverage-report/scoverage.xml
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
${{ runner.os }}-scala-${{ matrix.scala.version }}-
- name: Run tests
if: ${{ env.combo_enabled == 'true' }}
run: sbt ++${{ matrix.scala.version }} clean guardrail/clean coverage "runExample scala ${{ matrix.framework.framework }}" ${{ matrix.framework.project }}/test coverageAggregate
run: sbt ++${{ matrix.scala.version }} clean samples/clean coverage "runExample scala ${{ matrix.framework.framework }}" ${{ matrix.framework.project }}/test coverageAggregate
- uses: codecov/codecov-action@v1
if: ${{ env.combo_enabled == 'true' }}
with:
Expand Down
28 changes: 28 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
Migrating to guardrail-core 0.71.0
==================================

[#1407](https://github.com/guardrail-dev/guardrail/pull/1407) resolved some long-standing technical debt, unifying two different type resolution codepaths.

The major deviation between the two was how `array` was handled. Previously, many parameters were generated as `Iterator`, now they are generated as `Vector`.

Should you prefer the previous functionality, `x-scala-array-type` can be added to your specification in order to override the new default.

```diff
openapi: 3.0.2
paths:
/foo:
post:
parameters:
- name: vector
in: query
required: true
schema:
type: array
+ x-scala-array-type: Iterator
items:
type: integer
format: int64
```

There is a [scalafix rule](https://raw.githubusercontent.com/guardrail-dev/guardrail-scalafix-rules/master/rules/src/main/scala/fix/GuardrailIteratorToVector.scala) that will also attempt to apply this change to method signatures throughout your codebase.

Migrating to 0.62.0
===================

Expand Down
7 changes: 4 additions & 3 deletions modules/core/src/main/scala/dev/guardrail/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ object Common {
globalSecurityRequirements = NonEmptyList
.fromList(swagger.downField("security", _.getSecurity).indexedDistribute)
.flatMap(SecurityRequirements(_, SecurityRequirements.Global))
requestBodies <- extractCommonRequestBodies(swagger.downField("components", _.getComponents))
components = swagger.downField("components", _.getComponents)
requestBodies <- extractCommonRequestBodies(components)
routes <- extractOperations(paths, requestBodies, globalSecurityRequirements)
prefixes <- Cl.vendorPrefixes()
securitySchemes <- SwaggerUtil.extractSecuritySchemes(swagger.unwrapTracker, prefixes)
Expand All @@ -87,15 +88,15 @@ object Common {
case CodegenTarget.Client =>
for {
clientMeta <- ClientGenerator
.fromSwagger[L, F](context, frameworkImports)(serverUrls, basePath, groupedRoutes)(protocolElems, securitySchemes)
.fromSwagger[L, F](context, frameworkImports)(serverUrls, basePath, groupedRoutes)(protocolElems, securitySchemes, components)
Clients(clients, supportDefinitions) = clientMeta
frameworkImplicits <- getFrameworkImplicits()
} yield CodegenDefinitions[L](clients, List.empty, supportDefinitions, frameworkImplicits)

case CodegenTarget.Server =>
for {
serverMeta <- ServerGenerator
.fromSwagger[L, F](context, supportPackage, basePath, frameworkImports)(groupedRoutes)(protocolElems, securitySchemes)
.fromSwagger[L, F](context, supportPackage, basePath, frameworkImports)(groupedRoutes)(protocolElems, securitySchemes, components)
Servers(servers, supportDefinitions) = serverMeta
frameworkImplicits <- getFrameworkImplicits()
} yield CodegenDefinitions[L](List.empty, servers, supportDefinitions, frameworkImplicits)
Expand Down
Loading